View Categories

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

Connect · GA4 to Google Sheets

Get data from GA4 into Google Sheets

Pull live rows from your GA4 account into Google Sheets and refresh them whenever you like. No CSV uploads, no Apps Script, no copy-paste. About ten minutes the first time, and the Free plan covers it.

About 10 minutes No coding needed Credentials stay with you Any browser, any device
Stuck at any point? Just ask us. Open Support in Query Streams (top-right menu → Support) and send us a message. Real people read it, and “I don’t know what this screen is asking for” is a perfectly good question.

What you’ll end up with

Google Analytics 4 logoA Google Sheet showing the live results of a SQL query against your GA4 account, with a button that pulls the latest rows whenever the data changes. Like this:

Google Analytics 4 holds your data behind its API. Getting it into Google Sheets usually means exporting a CSV from the GA4 dashboard every time you need fresh numbers. Query Streams skips that: a small helper program called the Agent runs the query where your data is, and a Google Sheets add-on asks it for the rows you want. Only the results travel, over an encrypted link, and Google Sheets can be anywhere: any browser on any device.

WHERE THE AGENT RUNSany always-on computer or server with internetYour GA4 accountkeys stay hereQuery Streams Agentholds the credentialsQuery Streamsencrypted linkover the internet · results onlyWHEREVER YOU AREany browser: laptop, tablet, phone, ChromebookGoogle Sheetsrows arrive in a sheet
The Agent lives with your data. Your sheet lives in Google’s cloud. Open it anywhere and the rows come to you.

What you’ll need

A Query Streams account

The Free plan is enough for this guide. Sign up at my.querystreams.com.

The Agent on any always-on computer

A small program that runs in the background and calls GA4 when Google Sheets asks. It just needs internet access.

Your GA4 login

You will sign in to GA4 once and allow read access. No passwords are typed into Query Streams.

Which computer gets the Agent? Any always-on machine that can already reach your GA4 account. Google Sheets can be anywhere; it runs in your browser.

Connect it in five steps

  1. Create your account

    Go to my.querystreams.com and sign up. Pick the Free plan. It is a real plan, not a trial, and it covers connecting your GA4 account and running queries from Google Sheets.

  2. Install the Agent on any always-on computer

    Sign in, open Download, and install the Agent on any always-on computer or server with internet access. It takes a minute and starts on its own from then on.

    Why a small program instead of a driver? The Agent is one install for Windows, Mac or Linux (about 85 MB on Windows, a little over 100 MB on Mac and Linux) that runs quietly in the background. It makes one outbound, encrypted connection to Query Streams, the same way a browser does, so you open no firewall port and set up no VPN. Your keys stay on that machine, and the rows travel to wherever you are, across the internet if need be. The only thing on your side is the add-on.

    The Download page shows Your Access Key. Paste it into the Agent when it asks, and wait for the badge to read Connected to Query Streams. That is the only thing you do on the Agent itself.

    Full walkthroughs if you want them: Windows, Mac, Linux.

  3. Point it at your GA4 account

    Back in your browser, open Data Agents (under Data in the top menu). Your Agent is listed there. Click Add connector and choose Google Analytics 4. Need your GA4 credentials first? Open the walkthrough, then fill in:

    Create your GA4 credentials (about 15 minutes)

    Follow this with Google Analytics 4 open in another tab. Query Streams keeps what you create here so your Agent can use it, and only ever reads from Google Analytics 4.

    Who can do this
    Google Analytics: Administrator on the GA4 property or its account (needed to add the service account). Google Cloud: Owner of the project (you are Owner of any project you create), or the Create Service Accounts, Service Account Key Admin and Service Usage Admin roles on it.
    Recommended
    Google Cloud service account JSON key (a .json file of type service_account), with the service account added as Viewer on the GA4 property

    Before you start

    • A GA4 property. Its Property ID is a plain number. A UA- tracking ID means an old Universal Analytics property, which Google’s API can’t read.
    • A Google account with the Administrator role on that GA4 property. If you don’t have it, you can do the Google Cloud part (steps 1 to 13) and ask an Administrator to do steps 14 to 19.
    • A Google Cloud project you can manage, or permission to create one. If your company’s Google Cloud organization was created on or after May 3, 2024, Google blocks key downloads by default and your Google Cloud administrator may need to allow it (see Common problems).
    • The Query Streams wizard open in another tab (Data Agents → Add connector → Google Analytics 4) with your Agent online.

    Steps

    1. Open the New Project page in Google Cloud

      Sign in with your Google account and open the Google Cloud New Project page.

      Already have a Google Cloud project you want to use? Skip to step 3 and pick it there. The first time you open Google Cloud, Google may ask for your country and for you to accept its Terms of Service before it shows the page.

    2. Name and create the project

      In Project name, type a name such as Query Streams GA4. Leave the organization or location box as Google fills it in (No organization is fine). Click Create.

      Google does not need a billing account to create the project. Creating it takes a few seconds to a minute.

    3. Select the project

      Click the project picker at the top of the page, next to the Google Cloud logo, and click your project’s name. Every Google Cloud step below happens in this project.

      The most common mistake is enabling the API in one project and creating the key in another. Check the project name at the top of the page before each Google Cloud step.

    4. Enable the Google Analytics Data API

      Open the Google Analytics Data API page in the API Library. Check that your project’s name shows at the top, then click Enable.

      Pick Google Analytics Data API, not Google Analytics Reporting API, which only works with old Universal Analytics properties. If the button says Manage instead of Enable, the API is already on. This one API also serves GA4’s realtime report, so there is nothing extra to enable for the realtime_active_users table.

    5. Enable the Google Analytics Admin API (recommended)

      Open the Google Analytics Admin API page in the API Library and click Enable.

      Syncing doesn’t need this API. It powers the Detect button next to GA4 Property ID in the Query Streams wizard, which lists the properties the service account can see. Skip it if you will type the Property ID yourself.

    6. Start a service account

      Open the Service accounts page. From inside Google Cloud you can also open the Navigation menu (three lines, top left) and choose IAM & Admin → Service Accounts. Click + Create service account.

      Already made a service account for Query Streams’ Google Search Console connector? You can use it here too: do steps 4 and 5 in its project, then go to step 14 with its email and key.

    7. Name the service account

      In Service account name, type query-streams-ga4. Google fills in Service account ID from it. The description is optional. Click Create and continue.

      The ID can’t be changed later. It becomes the first part of the service account’s email address.

    8. Skip the project roles

      The next section offers roles on the project. Leave the role box empty and click Continue.

      Don’t give the service account Owner, Editor or Viewer here. Its access to Google Analytics is granted inside Google Analytics in step 18. A project role does nothing in Google Analytics and only widens what the key can do in Google Cloud.

    9. Finish creating the service account

      Leave the last section (people who can use or manage the service account) empty and click Done. You are back on the Service accounts list.

    10. Copy the service account email

      In the list, find the new account. Its email looks like [email protected]. Copy it and keep it for step 17.

      Copy the whole address, through .iam.gserviceaccount.com. A new service account can take a minute or more before it is usable.

    11. Open the Keys tab

      Click the service account’s email address, then click the Keys tab.

    12. Start a new key

      Click Add key, then choose Create new key.

      If Google says Service account key creation is disabled, your organization blocks key downloads. See Common problems.

    13. Download the JSON key

      Choose JSON as the key type and click Create. Your browser downloads a .json file named after your project, usually into your Downloads folder.

      This download happens once: Google keeps no copy, and you can’t download the file again. If you lose it, create a new key and delete the old one. Don’t choose P12. Keep the file private. Don’t email it or put it in a shared folder, because anyone who has it can read your Analytics data. Query Streams stores it for your Agent and only ever reads with it.

    14. Open Google Analytics Admin

      Open Google Analytics and click Admin (the gear icon at the bottom left). At the top of the page, check that the account and property picker shows the GA4 property you want to read.

      To add users you need the Administrator role on this property or its account. If you don’t have it, send the email from step 10 to someone who does and ask them to do steps 15 to 19.

    15. Open Property access management

      Under Property settings, in the Property group, click Property access management.

      Use Property access management, not Account access management. Access added at account level reaches every property in the account.

    16. Add a user

      Click the blue + button at the top right and choose Add users.

    17. Enter the service account email

      Paste the service account email from step 10 into the email box. Untick Notify new users by email.

      Nobody reads that address’s inbox, so there is no point notifying it. If GA4 answers This email doesn’t match a Google Account or Failed to add user: email not found, see Common problems. Google has had a known problem with newly created service accounts since April 2026, and waiting a few hours has fixed it for many people.

    18. Choose the Viewer role

      In the role list, choose Viewer. Leave the data restrictions No Cost Metrics and No Revenue Metrics unticked.

      Viewer is enough, because Query Streams only reads reports. With No Revenue Metrics ticked, Google returns 0 in every revenue column of the ecommerce_overview and transactions tables.

    19. Add the service account

      Click Add at the top right. The service account now appears in the property’s user list with the Viewer role.

      Some screens label this button Create.

    20. Copy the Property ID

      Go back to Admin. Under Property settings, in the Property group, click Property details. At the top right, PROPERTY ID shows a number such as 486480978. Click the copy icon next to it.

      Use this number, not the Measurement ID (which starts with G-) and not the Account ID. The same number appears in the GA4 address bar after the letter p, for example …/p486480978/….

    21. Copy the whole key file

      Open the .json file from step 13 in a plain text editor. On Windows, right-click the file and choose Open with → Notepad. On a Mac, Control-click it and choose Open With → TextEdit. Press Ctrl+A, then Ctrl+C (Cmd+A, then Cmd+C on a Mac).

      Copy everything from the first { to the last }. Don’t retype or tidy any part of it. The private_key line must stay exactly as Google wrote it.

    Permissions to grant

    ResourceAccessUsed for
    Google Analytics property role: Viewer (Property access management)ViewerEvery ga4 table: traffic_overview, traffic_sources, geographic_data, page_views, user_engagement, events, ecommerce_overview, transactions and realtime_active_users. Test connection also reads the property’s field list with it.
    Data restriction: No Revenue MetricsUntickedRevenue columns in ecommerce_overview (purchase_revenue, total_revenue, average_purchase_revenue) and transactions (item_revenue). When ticked, Google returns 0 in them.
    Data restriction: No Cost MetricsUnticked (recommended)No current Query Streams table reads cost metrics, so this one does no harm today. Leaving it unticked keeps any cost data readable.
    Google Cloud API: Google Analytics Data APIEnabledEvery ga4 table and Test connection. The realtime report behind realtime_active_users is part of the same API.
    Google Cloud API: Google Analytics Admin APIEnabled (optional)Only the Detect button next to GA4 Property ID, which lists the properties the service account can see. No table reads it.
    Google Cloud project role for the service accountNoneNot needed for any table. Google Analytics access comes only from the Viewer role above.
    OAuth scope https://www.googleapis.com/auth/analytics.readonlyRequested by the Agent (nothing for you to set)Every ga4 table, Test connection and Detect. It is Google’s read-only Analytics scope, so the key can’t change anything in Google Analytics.

    Paste into Query Streams

    Service Account JSON Key
    The whole contents of the .json file you copied in step 21, from the first { to the last }. When you edit a connector later, leave this box blank to keep the stored key, or paste a whole new file to replace it.
    GA4 Property ID
    The number you copied in step 20, digits only (for example 486480978). Or click Detect next to the box and pick your property from the list. Detect needs the Admin API from step 5 and an Agent that is online.

    Common problems

    Test connection fails with Invalid key type. Expected ‘service_account’.

    Why: The pasted file is not a service account key. Usually it is an OAuth client file (named like client_secret_….json) or an API key from APIs & Services → Credentials.

    Fix: Create a JSON key on the service account (steps 11 to 13) and paste that file. A service account key contains the line “type”: “service_account”.

    Test connection fails with Invalid JSON format, or with Missing or empty ‘private_key’ field.

    Why: Only part of the file was copied, or the text was changed while copying.

    Fix: Open the file again in Notepad or TextEdit, press Ctrl+A (Cmd+A on a Mac), copy, and paste it into Service Account JSON Key with nothing before or after it.

    Test connection fails with Forbidden – User does not have sufficient permissions for this property.

    Why: The service account was not added to this property, was added to a different property, or the Property ID belongs to another property. It also happens for a few minutes right after you add the service account.

    Fix: Open the property whose Property details show the same Property ID and check that the service account email is listed in Property access management with Viewer (steps 14 to 19). Wait 5 to 10 minutes, then click Test again.

    Test connection fails with a Forbidden message saying Google Analytics Data API has not been used in project … before or it is disabled.

    Why: The Data API is not enabled in the Google Cloud project the key belongs to. The project is named in the key file’s project_id line.

    Fix: Select that project in Google Cloud, enable Google Analytics Data API (step 4), wait a few minutes, and click Test again.

    Test connection fails with Invalid Property ID format: ‘G-…’. Should be numeric, or with Property ‘…’ not found.

    Why: The Measurement ID (G-…), an old UA- tracking ID, or a mistyped number was entered instead of the Property ID.

    Fix: Copy the number shown under PROPERTY ID on the Property details page (step 20) and paste it into GA4 Property ID.

    Google Analytics won’t accept the service account email: This email doesn’t match a Google Account, or Failed to add user: email not found.

    Why: A known Google problem: since late April 2026, GA4 and Search Console sometimes don’t recognise newly created service accounts for a while. Reports continued into September 2026. A typo or a space in the address causes the same message.

    Fix: Paste the address again with no spaces. If it is still refused, wait a few hours and try again. A service account created earlier usually works, so if you have one, create a new key for it (steps 11 to 13) and add that email instead. An administrator who is comfortable with Google’s API Explorer can also add the service account with the Admin API’s accessBindings.create method and the role predefinedRoles/viewer.

    Google Cloud shows Service account key creation is disabled when you click Create new key.

    Why: Your organization enforces the policy iam.disableServiceAccountKeyCreation. Google turns it on by default for organizations created on or after May 3, 2024.

    Fix: Ask your Google Cloud administrator (someone with the Organization Policy Administrator role) to allow key creation for this project or service account. Google documents a tag-based exemption for one project or service account. Then repeat steps 12 and 13.

    Detect says No GA4 properties found, or reports that the Google Analytics Admin API has not been used in the project.

    Why: The Admin API is not enabled (step 5), or the service account has not been added to any property yet.

    Fix: Enable the Admin API and finish steps 14 to 19, then click Detect again. You can always type the Property ID yourself instead.

    The ecommerce_overview and transactions tables sync, but every revenue column is 0.

    Why: The service account was added with the No Revenue Metrics data restriction.

    Fix: In Property access management, open the service account’s entry, untick No Revenue Metrics and save. The next sync reads the real values.

    A connector that used to work stops syncing, with an error that mentions invalid_grant or Invalid JWT Signature.

    Why: The key was deleted or disabled in Google Cloud. Google also disables keys it finds exposed in public.

    Fix: Create a new key (steps 11 to 13). In Query Streams, open the connector in Data Agents, click Edit, paste the whole new file into Service Account JSON Key, click Test connection, then click Save changes. Delete the old key in Google Cloud.

    Syncs fail with 429 or RESOURCE_EXHAUSTED.

    Why: The property used up its Google Analytics API quota. Every app that reads this property through the API draws on the same per-property quota.

    Fix: Wait: hourly quota refills within an hour, and daily quota resets at midnight Pacific Time. Turn off tables you don’t use, or sync them less often.

    You want Query Streams to stop reading this property.

    Why: Deleting the connector does not remove Google’s access. The service account stays a Viewer and the key stays valid.

    Fix: In Property access management, remove the service account. In Google Cloud, open the service account’s Keys tab and delete the key. Then delete the connector in Data Agents.

    Limits to know

    • Data freshness: GA4 can take 24 to 48 hours to finish processing a day, and figures for recent days can change after that. Each sync of the daily tables re-reads the last 3 days, so late numbers fill in on their own. Realtime data arrives within minutes.
    • Realtime window: GA4’s realtime report covers only the last 30 minutes (60 minutes on Analytics 360). The realtime_active_users table is a snapshot that each refresh replaces (every 5 minutes by default), not a history. It uses the same API, key and Viewer access as the other tables, with its own separate Realtime quota.
    • API quota for a standard property: 200,000 tokens per day and 40,000 per hour for the whole property, 14,000 per hour from one Google Cloud project, and 10 requests at a time. Most requests cost 10 tokens or fewer. Analytics 360 properties get 10 times these limits. Daily quota resets at midnight Pacific Time.
    • History: the first sync asks for everything since October 2020, when GA4 launched. Google returns data only from when your property started collecting. Universal Analytics (UA-) properties can’t be read through this API.
    • One property per connector: the Property ID selects one GA4 property. To read another property, add the same service account to it as Viewer and create a second connector. The same key works for both.
    • Keys: a service account key never expires unless your organization sets a maximum lifetime. Each service account can have up to 10 keys, and the key file can be downloaded only once.
    • Data restrictions: if the service account has No Revenue Metrics or No Cost Metrics, Google returns 0 for those metrics instead of an error.

    Steps verified 8 October 2026. Sources: developers.google.com/analytics/devguides/reporting/data/v1, developers.google.com/analytics/devguides/reporting/data/…, developers.google.com/analytics/devguides/reporting/data/…, developers.google.com/analytics/devguides/reporting/data/…, developers.google.com/analytics/devguides/reporting/data/…, developers.google.com/analytics/devguides/reporting/data/…, developers.google.com/analytics/devguides/reporting/data/…, developers.google.com/analytics/devguides/reporting/data/…, developers.google.com/analytics/devguides/reporting/data/…, developers.google.com/analytics/devguides/config/admin/v1…, developers.google.com/analytics/devguides/config/admin/v1…, developers.google.com/analytics/devguides/config/admin/v1…, developers.google.com/workspace/guides/create-project, docs.cloud.google.com/resource-manager/docs/creating-mana…, docs.cloud.google.com/service-usage/docs/enable-disable, docs.cloud.google.com/iam/docs/service-accounts-create, docs.cloud.google.com/iam/docs/keys-create-delete, docs.cloud.google.com/iam/docs/service-account-creds, docs.cloud.google.com/iam/docs/troubleshoot-org-policies, docs.cloud.google.com/iam/docs/best-practices-for-managin…, support.google.com/googleapi/answer/6158841?hl=en, support.google.com/analytics/answer/9305788?hl=en, support.google.com/analytics/answer/9305587?hl=en, support.google.com/analytics/answer/9304776?hl=en, support.google.com/analytics/answer/11198161?hl=en, docs.ovhcloud.com/en/guides/public-cloud/data-platform/co…, windsor.ai/documentation/how-to-connect-ga4-to-windsor-ai…, seopress.org/support/guides/find-my-google-analytics-4-pr…, analytify.io/add-user-to-google-analytics, optimizesmart.com/blog/google-analytics-4-measurement-id-…, discuss.google.dev/t/problem-with-new-service-accounts/36…, piunikaweb.com/2026/05/01/google-service-account-email-no…, sanj.dev/post/google-analytics-search-console-service-acc…, oneuptime.com/blog/post/2026-01-24-gcp-service-account-ke…, help.genesys.cloud/articles/data-action-returns-a-400-error.

    Connection name
    Any name you will recognise later, like Sales database.
    Service Account JSON Key
    Paste the contents of the key file for a Google service account that has been added as a viewer on your GA4 property.
    GA4 Property ID
    The number that identifies your GA4 property, found in GA4 Admin under Property settings, like 486480978.

    Click Test connection. When it reads Connected, click Save. The connection reaches your Agent within a few seconds.

    Test failed? Usually a missing permission, or a credential from the wrong GA4 account. The walkthrough above lists the common problems and their fixes.

  4. See your data in Query Builder Optional

    You can look at your GA4 account before Google Sheets is involved at all. Open Query Builder in the portal and pick the connection you just made. The Schema tab lists your tables and columns, and clicking one puts its name in the editor, so you can write a query without remembering exact names. Click Run and the rows appear under Results. Query Builder is on every plan, Free included.

    On Business plans you can also ask Nova in plain English (“show me customers in the USA”) and it writes the SQL for you. When the query looks right, save it: from Personal Core up it shows in the add-on’s Saved Queries list, and on any plan you can copy the SQL into the next step.

  5. Add Query Streams to Google Sheets

    Open any Google Sheet, go to Extensions → Add-ons → Get add-ons, search for Query Streams, and click Install. Or install it straight from Query Streams on the Google Workspace Marketplace. Google will ask you to allow the add-on; that is normal.

    Afterwards it is in every Google Sheet you open: a Query Streams icon in the side panel on the right, also listed under Extensions. There is no separate sign-in. It recognises the Google account you are already using, so that email needs to be the one on your Query Streams account.

  6. Pull in your first table

    Click the Query Streams icon in the side panel on the right of the sheet (or find it under Extensions). Choose Query Streamer and pick the connection you just made.

    Type the query you want to run. This one pulls a few columns from a ga4.traffic_overview table:

    Example · SQL
    SELECT date, sessions, total_users, screen_page_views
    FROM ga4.traffic_overview
    ORDER BY date DESC
    LIMIT 100;

    Under Destination Sheet pick the tab the rows should land in, then click Run Query. The rows land in that tab in a second or two. Click Run Query again any time the data has changed and the tab updates in place.

    Don’t know SQL? Build it in Query Builder first and paste it here, or pick it from Saved Queries if you saved it.

That’s it. Your data is in the sheet and stays current with one click. Nothing left your network except the rows you asked for.

Good next moves

  • Save the query in the portal so you can run it again with one click, from Google Sheets or Excel.
  • Add a filter such as a date range, so the same query can answer “this month” without editing.
  • Share the results with a colleague. They see the rows, not your credentials.

Questions people ask

Does your GA4 account have to be on the computer I use Sheets on?

No. Only the Agent has to be where your GA4 account is. Google Sheets runs in your browser on any device. Open the add-on with the same Google account and your connections are there.

Does my data get copied to Query Streams?

No. The Agent runs the query where your data is and sends only the rows it returns. Nothing is synced or stored in between.

Does the Free plan really cover this?

Yes. Free is a plan you keep, not a trial that expires. See exactly what it includes on the pricing page.

Does the sheet refresh by itself?

Click Run Query again whenever you want the latest rows. For a sheet that refreshes on a schedule without anyone pressing anything, set up an Automation in the Query Streams portal (Streams → Automation). It is on every plan.

Still stuck? Open Support in Query Streams and tell us which step you are on and what you see. We will get you connected.
Query Streams also connects the same data toExcelClaude, Cursor and ChatGPTa REST APIand more

Every guide for GA4

Not quite your setup?

  • Want the Google searches that bring people to your site, with clicks and impressions? Google Search Console has them → Search Console

Setup trouble?

  • Agent shows Offline, or Test connection and Browse are greyed out? Check that the Agent is online → Is the Agent online?
Updated on October 17, 2026

Powered by BetterDocs