View Categories

How to Connect Google Analytics to Google Sheets – Query Web Analytics with SQL

5 min read

Query Streams transforms your Google Analytics 4 data into SQL-queryable tables, letting you import live traffic, engagement, and e-commerce metrics directly into Google Sheets. No API coding, no manual exports—just write SQL queries and get GA4 analytics in your spreadsheet. Sign up free at QueryStreams.com and start querying your GA4 data in minutes.

8 GA4 Tables

Traffic, engagement, e-commerce, pages, events, and geographic data

Service Account Auth

No OAuth browser flow — just paste a JSON key for serverless authentication

AES-256 Encrypted

Your GA4 service account key stored securely on your network, never in the cloud

SQL-Powered Analytics

Write custom attribution, funnel, and cohort queries beyond the GA4 UI

What Google Analytics 4 Data Can You Access?

Query Streams syncs your GA4 data to an AES-256 encrypted local cache, transforming it into SQL-queryable tables. Note that GA4 data is typically 24–48 hours delayed by Google’s processing pipeline.

Traffic

  • traffic_overview Daily sessions, users, page views, engagement
  • traffic_sources Source/medium/campaign breakdown with conversions
  • geographic_data Users by country, region, and city

Engagement

  • page_views Page-level metrics with paths and titles
  • user_engagement Device, browser, and OS breakdown
  • events Event counts including conversion events

E-commerce

  • ecommerce_overview Revenue and transaction metrics
  • transactions Transaction and item-level details

Data Note

  • GA4 data has a 24–48 hour processing delay from Google
  • All tables sync daily — more frequent sync won’t yield new data
  • Each table includes a raw_data JSON column with the full API response

Prerequisites

1
Query Streams Account

Sign up free — no credit card required

2
Query Streams Network Agent

Windows service installed on your network. Install guide

3
Google Cloud Project

With the Google Analytics Data API and Analytics Admin API enabled

4
Google Service Account

JSON key file with Viewer access granted in your GA4 property

5
Google Sheets

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

Setup Guide

1Install Agent
2Service Account
3Add Connector
4Sync Schedule
5Install Add-on

Step 1: Install the Query Streams Network Agent

  1. Log in to my.querystreams.com
  2. Navigate to Network Agents in the left sidebar
  3. Click Download Agent and run the Windows installer
  4. The agent installs as a Windows service and connects automatically
  5. Your agent appears as “Online” in the portal within 30 seconds

Step 2: Create a Google Cloud Service Account

  1. Go to the Google Cloud Console and create or select a project
  2. Navigate to APIs & ServicesLibrary → enable Google Analytics Data API and Google Analytics Admin API
  3. Go to IAM & AdminService AccountsCreate Service Account
  4. Name it (e.g., “query-streams-ga4”) and click Create and Continue
  5. Skip the optional role assignment → click Done
  6. Click on the service account → Keys tab → Add KeyCreate new keyJSON
  7. The JSON key file downloads automatically — save it securely

Grant Access in GA4

  1. Go to Google Analytics and select your GA4 property
  2. Click AdminProperty Access Management
  3. Click +Add users
  4. Paste the client_email from your JSON key
  5. Select the Viewer role → click Add

Step 3: Add the Google Analytics 4 Connector

  1. Open the Network Agent interface at http://localhost:1823
  2. Click Add Connection and select Google Analytics 4
  3. Paste the contents of your Service Account JSON key (or upload the file)
  4. Select your GA4 Property from the dropdown
  5. Click Next to configure sync schedules and install pre-built queries

Step 4: Configure Your Sync Schedule

All GA4 Tables (8 tables)Every 24 hours — GA4 data is 24–48h delayed by Google
Initial SyncFetches historical data up to your configured lookback window

Syncing GA4 more frequently than daily won’t produce new data — Google’s processing pipeline typically has a 24–48 hour delay. Set your sync to run once daily at a low-traffic time for efficiency.

Step 5: Install the Google Sheets Add-on

  1. Open Google Sheets in your browser
  2. Go to ExtensionsAdd-onsGet add-ons
  3. Search for “Query Streams”
  4. Click Install and grant the required permissions
  5. Access it via ExtensionsQuery StreamsOpen
  6. Sign in with your Query Streams account credentials
  7. Or install directly: Install Query Streams for Google Sheets

You’re connected! Open Query Streams in Google Sheets, click Saved Queries, and find your Google Analytics folder with pre-built queries for traffic trends, channel attribution, conversion tracking, and more. Select any query and click Run to pull GA4 data into your spreadsheet.

Example Google Analytics 4 SQL Queries

Weekly Traffic Trend (Last 90 Days)
SELECT
    DATE_TRUNC('week', date) AS week,
    SUM(sessions) AS sessions,
    SUM(total_users) AS users,
    SUM(new_users) AS new_users,
    ROUND(AVG(bounce_rate) * 100, 1) AS avg_bounce_rate_pct
FROM ga4.traffic_overview
WHERE date >= CURRENT_DATE - INTERVAL '90 days'
GROUP BY DATE_TRUNC('week', date)
ORDER BY week DESC;
Top Traffic Channels (Last 30 Days)
SELECT
    session_default_channel_group AS channel,
    SUM(sessions) AS sessions,
    SUM(total_users) AS users,
    SUM(conversions) AS conversions,
    ROUND(AVG(engagement_rate) * 100, 1) AS engagement_rate_pct
FROM ga4.traffic_sources
WHERE date >= CURRENT_DATE - INTERVAL '30 days'
GROUP BY channel
ORDER BY sessions DESC
LIMIT 10;
Conversion Events (Last 30 Days)
SELECT
    event_name,
    SUM(event_count) AS total_events,
    SUM(total_users) AS unique_users,
    ROUND(AVG(event_count_per_user), 2) AS events_per_user
FROM ga4.events
WHERE is_conversion = true
  AND date >= CURRENT_DATE - INTERVAL '30 days'
GROUP BY event_name
ORDER BY total_events DESC;

Share GA4 Reports Without Sharing Credentials

Open any GA4 query in the Query Builder → click the Sharing tab → enter email addresses → click Share. Recipients get analytics data in their Google Sheets add-on — without access to your Google Cloud service account, GA4 property admin, or SQL code.

Frequently Asked Questions

Does Query Streams support Universal Analytics (UA) or only GA4?
Query Streams supports Google Analytics 4 (GA4) only. Google sunset Universal Analytics on July 1, 2024, making GA4 the current standard. This connector works with your GA4 property.
Why is GA4 data always a day behind?
This is a GA4 platform limitation — Google processes analytics data with a 24–48 hour delay before it becomes available via the API. This affects all tools that read from the GA4 Data API. For intraday data, GA4 offers a separate intraday table not currently supported by Query Streams.
Can I connect multiple GA4 properties?
Yes. Add a separate connector for each GA4 property — each selects a different property from the dropdown during setup. All properties appear as distinct data sources, so you can query and compare multiple properties in a single SQL statement.
Can I combine GA4 data with Google Search Console in the same query?
Yes. If you have both GA4 and Google Search Console connected, you can JOIN them in a single SQL query — for example, joining GA4 page views to GSC search analytics by page URL to correlate search rankings with on-site behavior.

Related Guides

Category: API Connectors

Tags: Google Analytics, GA4, Google Sheets, API, Web Analytics, SQL, Traffic, Conversions

Meta Description: Connect Google Analytics 4 to Google Sheets with SQL. Query traffic, engagement, and e-commerce data — no API coding required. Step-by-step setup guide.

Updated on June 3, 2026

Powered by BetterDocs