Sub topic 11
Linking GA4 to BigQuery
This chapter covers creating the link between a GA4 property and BigQuery. It assumes you can use GA4 Admin, know what events and event parameters are, and have a Google Cloud project with billing available. The export tables, UNNEST queries and costs get their own chapters, so this one stops once the data is flowing.
What the link does
The BigQuery link copies the raw, event-level data that GA4 collects into a BigQuery dataset in your own Google Cloud project. Data flows in one direction, from GA4 to BigQuery. Nothing in BigQuery changes GA4 reports.
Unlike GA4 reports, the export is not sampled or aggregated. Each row is one event. That makes it the right source for joins with CRM or sales data, custom attribution, and any question the GA4 interface cannot answer.
Two limits to know before you start:
- The export is not retroactive. Only events collected after the link is active are exported. GA4 does not backfill earlier history.
- The export is not a copy of the reports. Some report features, such as modeled data and thresholding, are not part of the raw export. This is one reason numbers differ across tools, covered in the last chapter.
Requirements
You need access in two places.
| Where | What you need |
|---|---|
| GA4 property | The Editor role (or Administrator) on the property |
| Google Cloud project | Owner access on the project you want to link |
| Google Cloud project | The BigQuery API enabled (it is on by default in most projects) |
| Google Cloud project | Billing enabled if you want streaming export or storage beyond the free allowance |
The two roles are usually held by different people. A common failure is that the analyst has GA4 Editor but not Owner on the Cloud project, so the project does not appear in the picker. Ask a Cloud Owner to start the link, or to grant you the role temporarily.
If the BigQuery API is off, enable it before you start:
gcloud services enable bigquery.googleapis.com --project=my-projectCreate the link
- In GA4, open Admin and, under Product links, choose BigQuery links.
- Select Link.
- Choose BigQuery project. The list shows projects where your Google account has Owner access. Select one and confirm.
- Choose the data location for the dataset, then select Next.
- Under Configure settings, pick which data streams to export. Optionally exclude specific events, and choose whether to include advertising identifiers.
- Choose the frequency: daily, streaming, or both. Standard properties can also export user data. The next chapter compares these options.
- Review the settings and select Submit.
The link appears in the list right away. Data does not. The first daily table usually arrives within 24 hours.
Choose the location carefully
The dataset location is fixed when the link is created. You cannot edit it later. To change it you must delete the link and create a new one, and data already exported stays in the old location. BigQuery cannot join tables across locations in one query, so pick the location that matches your other datasets. For example, if your CRM tables are in the EU multi-region, put the GA4 dataset there too. Data-residency rules at your organization may also decide the choice.
What the link creates
GA4 creates a dataset named analytics_ followed by the property ID. For property 123456789 that is analytics_123456789. To let GA4 write into it, the link grants a Google-managed service account, [email protected], two roles on your project: BigQuery Job User and BigQuery Data Editor. Do not remove that service account or its roles. If you do, the export fails silently from your side, and you will see missing days.
How the pieces connect
Verify that data arrives
After 24 hours, list the dataset's contents with the bq command-line tool:
bq ls --project_id=my-project analytics_123456789
bq ls --project_id=my-project --max_results=5 analytics_123456789You should see tables named events_YYYYMMDD, one per day. With streaming enabled you will also see an events_intraday_YYYYMMDD table for the current day. If you chose user export, expect user-level tables as well.
If the dataset does not exist yet, wait a full day before troubleshooting. Creation of the dataset can lag behind the moment you press Submit.
To confirm the service account still holds its roles, check the project's IAM policy:
gcloud projects get-iam-policy my-project \
--flatten="bindings[].members" \
--filter="bindings.members:[email protected]" \
--format="table(bindings.role)"The output should list roles/bigquery.dataEditor and roles/bigquery.jobUser.
Common problems
- The project is missing from the picker. Your account lacks Owner access on that project, or you are signed in with a different Google account than expected.
- The link was created but no tables appear after two days. Check that the service account and its roles still exist, that billing is enabled for the project, and that the link is not disabled in Admin > Product links > BigQuery links.
- Exports stop after working for a while. Standard properties have a daily limit of about one million events for the daily export. If the property exceeds it repeatedly, GA4 can pause the daily export and notify you in the interface. Reduce volume by excluding noisy events, or move to GA4 360, which has a much higher limit. Streaming export is not subject to that same cap.
- Someone deleted the dataset. Deleting
analytics_<id>does not stop the link. GA4 recreates the dataset and resumes exporting, but earlier data is gone. Treat the dataset as the only copy. - Wrong location chosen. Delete the link, create it again with the right location, and accept that earlier days stay behind.
A property can have more than one link, up to a documented maximum per property. A common use is sending data to separate projects for development and production. Each link exports independently and has its own cost.
Practical guidance
Grant access to analysts on the dataset, not on the whole project, so they can query without being able to change the link's service account. Set a default table expiration only if you have decided you do not need long-term history, because expiration applies to every table GA4 writes. If you want history beyond what GA4 retains in its interface, the export is where it lives, so protect it.
Exercise
A colleague has the Editor role on a GA4 property but cannot see your Cloud project when creating the BigQuery link. What is the likely cause, and what are two things you could do?
Show answer
The project picker lists only projects where the signed-in account has Owner access, so the colleague probably lacks the Owner role on that Cloud project (or is signed in with a different account). You could grant them Owner on the project temporarily, or have a project Owner create the link instead, provided that person also has Editor on the GA4 property.
Exercise
You linked a property three days ago with the dataset location set to US, but your sales tables are in the EU. Can you edit the location, and what happens to the three days of exported data?
Show answer
No. The location is fixed at creation. You must delete the link and create a new one with the EU location. The three days already exported stay in the US dataset and are not moved, so you would need to copy them yourself if you want them alongside the new data.
Exercise
Which command lists the tables in the dataset for property 123456789 in project my-project, and what table names show that the daily export is working?
Show answer
bq ls --project_id=my-project analytics_123456789. Tables named events_YYYYMMDD, one per day, show that the daily export is working.