Obtenga datos de GA4 en Hojas de cálculo de Google
Importa filas en tiempo real de tu cuenta de GA4 a Google Sheets y actualízalas cuando quieras. Sin subir archivos CSV, sin usar Apps Script, sin copiar y pegar. La primera vez solo te llevará unos diez minutos, y el plan gratuito lo incluye.
Lo que obtendrás al final
Una hoja de cálculo de Google que muestra los resultados en tiempo real de una consulta SQL en tu cuenta de GA4, con un botón que muestra las filas más recientes cada vez que cambian los datos. Algo así:
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | customer_id | nombre de pila | apellido | país | total |
| 2 | 1042 | María | Álvarez | EE.UU | 1,284.50 |
| 3 | 1043 | Daniel | Okafor | EE.UU | 612.00 |
| 4 | 1047 | Priya | Nair | EE.UU | 2,090.75 |
| 5 | 1051 | Thomas | Iceberg | EE.UU | 338.20 |
| 6 | 1056 | Lucía | Ferreira | EE.UU | 1,455.00 |
| 7 | 1060 | Kenji | Sato | EE.UU | 874.10 |
| 8 |
Google Analytics 4 almacena tus datos en su API. Para importarlos a Google Sheets, normalmente tienes que exportar un archivo CSV desde el panel de control de GA4 cada vez que necesites datos actualizados. Query Streams evita este paso: un pequeño programa auxiliar llamado Agente ejecuta la consulta donde se encuentran tus datos, y un complemento de Google Sheets solicita las filas que necesitas. Solo se transmiten los resultados, a través de un enlace cifrado, y Google Sheets puede estar en cualquier lugar: en cualquier navegador y en cualquier dispositivo.
Lo que necesitarás
Una cuenta de Query Streams
El plan gratuito es suficiente para esta guía. Regístrate en mi.querystreams.com.
El agente en cualquier ordenador que esté siempre encendido
Un pequeño programa que se ejecuta en segundo plano y llama a GA4 cuando Google Sheets lo solicita. Solo necesita acceso a internet.
Tu inicio de sesión de GA4
Deberá iniciar sesión en GA4 una sola vez y otorgar acceso de lectura. No es necesario introducir contraseñas en los flujos de consulta.
¿Qué ordenador recibe el Agente? Cualquier máquina que esté siempre encendida y que ya pueda acceder a tu cuenta de GA4. Google Sheets puede estar en cualquier lugar; se ejecuta en tu navegador.
Conéctalo en cinco pasos
-
Crea tu cuenta
Ir a mi.querystreams.com y regístrese. Elija el Gratis Es un plan real, no una versión de prueba, y cubre la conexión de tu cuenta de GA4 y la ejecución de consultas desde Google Sheets.
Instale el agente en cualquier ordenador que esté siempre encendido.



Iniciar sesión, abrir DescargarInstale el Agente en cualquier ordenador o servidor que esté siempre encendido y tenga acceso a internet. El proceso tarda un minuto y, a partir de ese momento, se inicia automáticamente.
¿Por qué un programa pequeño en lugar de un controlador? El Agente es una única instalación para Windows, Mac o Linux (aproximadamente 85 MB en Windows, algo más de 100 MB en Mac y Linux) que se ejecuta discretamente en segundo plano. Establece una única conexión saliente cifrada a Query Streams, del mismo modo que lo hace un navegador, por lo que no es necesario abrir ningún puerto del firewall ni configurar una VPN. Tus claves permanecen en tu equipo y los datos se transmiten a dondequiera que estés, incluso a través de internet si es necesario. Lo único que necesitas es el complemento.
La página de descarga muestra Su clave de accesoPégalo en el Agente cuando te lo pida y espera a que aparezca la insignia. Conectado a flujos de consulta. Eso es lo único que debes hacer en el propio Agente.
Si lo deseas, aquí tienes las guías completas: Ventanas, Impermeable, Linux.
-
Apúntalo a tu cuenta de GA4
De vuelta en tu navegador, abre Agentes de datos (bajo Datos (en el menú superior). Su agente aparece allí. Haga clic. Agregar conector y elegir 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.
- Recomendado
- Google Cloud service account JSON key (a .json file of type service_account), with the service account added as Viewer on the GA4 property
Antes de empezar
- 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
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- Open the Keys tab
Click the service account’s email address, then click the Keys tab.
- 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.
- 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.
- 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.
- 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.
- Add a user
Click the blue + button at the top right and choose Add users.
- 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.
- 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.
- 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.
- 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/….
- 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
Resource Acceda a Used for Google Analytics property role: Viewer (Property access management) Visor Every 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 Metrics Unticked Revenue 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 Metrics Unticked (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 API Enabled Every ga4 table and Test connection. The realtime report behind realtime_active_users is part of the same API. Google Cloud API: Google Analytics Admin API Enabled (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 account Ninguno Not needed for any table. Google Analytics access comes only from the Viewer role above. OAuth scope https://www.googleapis.com/auth/analytics.readonly Requested 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
- Clave JSON de la cuenta de servicio
- 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.
- ID de propiedad GA4
- 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.
- Nombre de la conexión
- Cualquier nombre que reconocerás más adelante, como base de datos de ventas.
- Clave JSON de la cuenta de servicio
- Pegue el contenido del archivo clave de una cuenta de servicio de Google que se haya agregado como visor en su propiedad de GA4.
- ID de propiedad GA4
- El número que identifica su propiedad de GA4, que se encuentra en la administración de GA4 en la configuración de la propiedad, como por ejemplo 486480978.
Haga clic en Probar la conexiónCuando se lee Conectado, haga clic GuardarLa conexión llega a su agente en cuestión de segundos.
¿La prueba falló? Usually a missing permission, or a credential from the wrong GA4 account. The walkthrough above lists the common problems and their fixes.
-
Agregar flujos de consultas a Google Sheets
Abre cualquier hoja de cálculo de Google, ve a Extensiones → Complementos → Obtener complementos, buscar Flujos de consultay haga clic Instale. O instálelo directamente desde Flujos de consultas en el Marketplace de Google WorkspaceGoogle te pedirá que permitas el complemento; eso es normal.
Después, aparece en cada Hoja de cálculo de Google que abres: un icono de Flujos de consulta en el panel lateral derecho, también listado en ExtensionesNo es necesario iniciar sesión por separado. Reconoce la cuenta de Google que ya estás usando, por lo que el correo electrónico debe ser el mismo que el de tu cuenta de Query Streams.
-
Trae tu primera mesa
Haga clic en el icono de Flujos de consulta en el panel lateral a la derecha de la hoja (o búsquelo en Extensiones). Elegir Transmisión de consultas y elige la conexión que acabas de hacer.
Escriba la consulta que desea ejecutar. Esta extrae algunas columnas de una ga4.traffic_overview mesa:
Ejemplo · SQLSELECCIONAR fecha, sesiones, usuarios_totales, vistas_de_página_de_pantalla DE ga4.traffic_overview ORDENAR POR fecha DESC LIMITAR 100;
Bajo Hoja de destino Seleccione la pestaña en la que deben aparecer las filas y, a continuación, haga clic. Ejecutar consultaLas filas aparecen en esa pestaña en uno o dos segundos. Haga clic en Ejecutar consulta nuevamente cada vez que los datos cambien y la pestaña se actualizará automáticamente.
¿No sabes SQL? Cree la consulta en el portal de Flujos de consultas. Generador de consultas Muestra tus tablas y columnas para que puedas seleccionarlas fácilmente. En los planes Business, también puedes pedirle a Nova que te muestre los clientes en EE. UU. y generará la consulta SQL automáticamente. Guarda la consulta y estará disponible con un solo clic en el portal y en la lista de Consultas guardadas del complemento, desde Personal Core en adelante.
Eso es todo. Tus datos están en la hoja de cálculo y se actualizan con un solo clic. Solo las filas que solicitaste salieron de tu red.
Buenos pasos a seguir
- Guardar la consulta en el portal para que puedas ejecutarlo de nuevo con un solo clic, desde Google Sheets o Excel.
- Agregar un filtro como un rango de fechas, de modo que la misma consulta pueda responder "este mes" sin necesidad de editarla.
- Comparte los resultados Con un colega. Ellos ven las filas, no tus credenciales.
Preguntas que hace la gente
¿Es necesario que mi cuenta de GA4 esté en el ordenador en el que uso Hojas de cálculo?
No. Solo el agente debe estar en la misma ubicación que tu cuenta de GA4. Google Sheets se ejecuta en tu navegador en cualquier dispositivo. Abre el complemento con la misma cuenta de Google y tus conexiones estarán disponibles.
¿Se copian mis datos a los flujos de consulta?
No. El agente ejecuta la consulta donde se encuentran sus datos y solo envía las filas que devuelve. No se sincroniza ni se almacena nada entretanto.
¿El plan gratuito realmente cubre esto?
Sí. Gratis es un plan que usted conserva, no una prueba que caduca. Vea exactamente lo que incluye en el página de precios.
¿La hoja se actualiza automáticamente?
Haz clic en Ejecutar consulta de nuevo cuando quieras ver las filas más recientes. Para que la hoja se actualice automáticamente según un horario, configura una automatización en el portal de Flujos de consulta (Flujos → Automatización). Esta función está disponible en todos los planes.
Guías relacionadas
Cada guía para GA4
¿No es exactamente lo que buscas?
- ¿Quieres que las búsquedas de Google que atraen visitantes a tu sitio web generen clics e impresiones? Google Search Console las tiene → Search Console

