View Categories

How to Connect HubSpot to Google Sheets – Query CRM Data with SQL

7 min read

Query Streams transforms your HubSpot CRM into SQL-queryable tables, letting you import live contacts, companies, deals, tickets, and pipeline data directly into Google Sheets. No API coding, no manual exports—just write SQL and get real-time CRM analytics in your spreadsheet. Sign up free at QueryStreams.com and start querying your HubSpot account in minutes.

25+ HubSpot Tables

Query contacts, deals, tickets, companies, and all engagement history

5-Minute Sync

Deals and tickets update every 5 minutes — pipeline always current

AES-256 Encrypted

API cache and credentials stored with military-grade encryption

Secure Sharing

Share query results without exposing your HubSpot credentials

What HubSpot Data Can You Access?

Query Streams syncs your HubSpot API data to an encrypted local cache, exposing it as SQL-queryable tables. Every table includes a raw_data JSON column with the complete API response — including all custom properties.

Core CRM

  • contacts
  • companies
  • deals
  • tickets
  • owners
  • pipelines & stages

Engagements

  • calls
  • emails
  • meetings
  • notes
  • tasks
  • communications

Commerce

  • quotes
  • invoices
  • subscriptions
  • payments
  • products
  • line_items

Marketing

  • forms & submissions
  • marketing_events
  • feedback_submissions
  • lists
  • workflows
  • associations

Prerequisites

1

Query Streams Account

Free account — no credit card required.

Create Free Account →
2

Query Streams Network Agent

Installed as a Windows service on your network. Creates a secure outbound-only connection.

Install the Agent →
3

HubSpot Account

Any HubSpot plan — Free, Starter, Professional, or Enterprise.

4

HubSpot Private App Token

A pat-xxx access token from a HubSpot Private App. No OAuth or browser redirects needed.

HubSpot Private Apps Docs →
5

Google Sheets Add-on

Query Streams add-on installed from the Google Workspace Marketplace.

Get Google Sheets Add-on →

Setup Guide

1
2
3
4
5

Step 1: Install the Query Streams Network Agent

  1. Log in to my.querystreams.com and go to Network Agents
  2. Click Download Agent and run the installer
  3. The agent installs as a Windows service and connects automatically
  4. Your agent appears as Online in the portal within 30 seconds
Outbound-only connection: The Network Agent makes outbound HTTPS connections only. No inbound ports, no firewall changes, no VPN required. Your HubSpot data never passes through Query Streams servers.
2
3
4
5

Step 2: Create a HubSpot Private App

Private Apps give you a simple access token — no OAuth flow, no browser redirects, no refresh token rotation.

  1. Log in to your HubSpot account
  2. Click the gear iconIntegrationsPrivate Apps
  3. Click Create a private app and give it a name (e.g., “Query Streams”)
  4. Go to the Scopes tab and enable: crm.objects.contacts.read, crm.objects.companies.read, crm.objects.deals.read, crm.objects.owners.read, tickets, e-commerce
  5. Click Create app, then Show token and copy the pat-xxx token
Read-only access: Query Streams only requests read scopes. We never create, update, or delete any HubSpot records. Your CRM data is safe.
3
4
5

Step 3: Add the HubSpot Connector

  1. Open the Network Agent interface at http://localhost:1823
  2. Click Add Connection → select HubSpot
  3. Paste your Private App Access Token (pat-xxx)
  4. Click Test Connection — Query Streams validates your token and displays your HubSpot portal ID
  5. Click Next — when prompted, keep Install Query Library queries enabled to get 20–50 pre-built HubSpot queries
  6. Click Save — the initial sync starts immediately
4
5

Step 4: Configure Your Sync Schedule

All HubSpot tables sync automatically. Adjust frequencies per table based on how time-sensitive the data is:

5 min
Deals & Tickets
Pipeline & support queue
15 min
Contacts & Companies
Active CRM records
15 min
Line Items
Deal products
Hourly
Products
Catalog updates
6 hrs
Owners & Pipelines
Rarely change
5

Step 5: Install the Google Sheets Add-on and Run Queries

  1. Open Google SheetsExtensionsAdd-onsGet add-ons
  2. Search for “Query Streams” and click Install
  3. Grant the required permissions
  4. Click ExtensionsQuery StreamsOpen to launch the sidebar
  5. Sign in with your Query Streams account
  6. Click Saved Queries → open the HubSpot folder — pre-built queries are organized by Pipeline, Contacts, Companies, Sales, and Support
  7. Select a query, adjust any filters, and click Run — live HubSpot data populates the sheet

You’re connected!

Your HubSpot data is live in Google Sheets. Run any saved query on demand — or parallel-run multiple queries into separate sheet tabs simultaneously.

Example HubSpot SQL Queries

Write custom queries in the Query Builder at my.querystreams.com and run them directly from Google Sheets.

Deal Pipeline Summary — 90-day forecast SQL
SELECT
    p.label            AS pipeline,
    ps.label           AS stage,
    COUNT(d.id)        AS deal_count,
    SUM(d.amount)      AS total_value,
    AVG(d.amount)      AS avg_deal_size
FROM hubspot.deals d
JOIN hubspot.pipelines p       ON d.pipeline  = p.id
JOIN hubspot.pipeline_stages ps ON d.dealstage = ps.id
WHERE d.closedate >= CURRENT_DATE
  AND d.closedate <= CURRENT_DATE + INTERVAL '90 days'
GROUP BY p.label, ps.label, ps.display_order
ORDER BY ps.display_order;
Win Rate by Sales Rep — last 90 days SQL
SELECT
    o.first_name || ' ' || o.last_name AS rep,
    COUNT(CASE WHEN json_extract_string(d.raw_data, '$.properties.hs_is_closed_won') = 'true' THEN 1 END) AS won,
    COUNT(CASE WHEN json_extract_string(d.raw_data, '$.properties.hs_is_closed') = 'true'
               AND json_extract_string(d.raw_data, '$.properties.hs_is_closed_won') = 'false' THEN 1 END) AS lost,
    ROUND(
        COUNT(CASE WHEN json_extract_string(d.raw_data, '$.properties.hs_is_closed_won') = 'true' THEN 1 END)::DECIMAL /
        NULLIF(COUNT(CASE WHEN json_extract_string(d.raw_data, '$.properties.hs_is_closed') = 'true' THEN 1 END), 0) * 100, 1
    ) AS win_rate_pct
FROM hubspot.deals d
JOIN hubspot.owners o ON d.hubspot_owner_id = o.id
WHERE d.updated_at >= CURRENT_DATE - INTERVAL '90 days'
GROUP BY o.id, o.first_name, o.last_name
ORDER BY win_rate_pct DESC;
Contact Lifecycle Funnel SQL
SELECT
    lifecyclestage,
    COUNT(*)                                                    AS contact_count,
    ROUND(COUNT(*)::DECIMAL / SUM(COUNT(*)) OVER () * 100, 1)  AS pct
FROM hubspot.contacts
WHERE lifecyclestage IS NOT NULL
GROUP BY lifecyclestage
ORDER BY
    CASE lifecyclestage
        WHEN 'subscriber'              THEN 1
        WHEN 'lead'                    THEN 2
        WHEN 'marketingqualifiedlead'  THEN 3
        WHEN 'salesqualifiedlead'      THEN 4
        WHEN 'opportunity'             THEN 5
        WHEN 'customer'                THEN 6
        ELSE 99
    END;

Share HubSpot Reports Without Sharing Credentials

Secure query sharing: Open any saved query → Sharing tab → enter emails → Share. Recipients see the query in their Excel and Google Sheets add-ons and can run it on demand for live data. They never see your SQL code, Private App token, or HubSpot account — zero technical setup required on their end.

Frequently Asked Questions

What HubSpot plan do I need? +
Any HubSpot plan works — Free, Starter, Professional, or Enterprise. Rate limits vary by plan (100–200 requests per 10 seconds), but Query Streams handles throttling automatically so you never hit an error.
🔒 Is my HubSpot data secure? +
Yes. The local API Cache is encrypted with AES-256 at rest. Your Private App token is stored encrypted on your machine. The Network Agent uses outbound-only HTTPS connections — no inbound ports, no firewall changes, no data passes through Query Streams servers.
⚙️ Can I access custom HubSpot properties? +
Yes. Every table stores the complete HubSpot API response in a raw_data JSON column. Access any custom property using: json_extract_string(raw_data, '$.properties.your_custom_field')
✏️ Can Query Streams modify my HubSpot data? +
No. Query Streams is strictly read-only. We never create, update, or delete any HubSpot contacts, deals, or records. The Private App scopes we request are all .read permissions.
⏱️ How fresh is the data in Google Sheets? +
Data freshness depends on your sync schedule. Deals and tickets can be as fresh as 5 minutes. When you click Run in the Google Sheets add-on, you always get the latest synced data — Query Streams uses incremental syncs with HubSpot's lastmodifieddate filter to only fetch changed records.

Related Guides

Category: API Connectors

Tags: HubSpot, Google Sheets, Google Sheets Add-on, CRM Data, HubSpot API, SQL Queries, Live Data, Contacts, Companies, Deals, Tickets, Pipeline, Sales Analytics, Query Streams

Meta Description: Connect HubSpot to Google Sheets with Query Streams. Import live contacts, companies, deals, and pipeline data using SQL queries. No API coding required.

Updated on June 3, 2026

Powered by BetterDocs