Sub topic 6
Keeping history beyond retention with BigQuery export
This chapter assumes you know the GA4 Admin area, can read an event with its parameters, and know that the event data retention setting (2 or 14 months on standard properties) limits how far back Explorations can look. It also assumes you have a Google Cloud project, or can create one. It covers how BigQuery export works as a long-term archive and where that archive stops being complete.
Why retention does not remove your history
The event data retention setting controls how long GA4 keeps user-level and event-level data for use in Explorations, segments, and audiences. Standard reports are built from aggregated data, so retention does not affect them.
BigQuery export is a separate copy. When you link a property to BigQuery, GA4 writes its raw events into a dataset in your Google Cloud project. From then on, that data is governed by your project's rules, not by the GA4 retention setting. Shortening retention in GA4 to 2 months does not delete rows already written to BigQuery.
This makes BigQuery the standard way to keep history that outlasts the 14-month limit. It also makes BigQuery a place where privacy obligations continue to apply, which later sections cover.
What the export contains
A link creates a dataset named analytics_<property ID>, for example analytics_123456789. Depending on the export types you enable, it holds these tables:
| Table | Export type | Contents |
|---|---|---|
| `events_YYYYMMDD` | Daily | One table per day with every exported event, one row per event. |
| `events_intraday_YYYYMMDD` | Streaming | Events for the current day, updated continuously. Replaced by the daily table. |
| `pseudonymous_users_YYYYMMDD` | Optional user export | Data about users identified by pseudonymous IDs such as the client ID. |
| `users_YYYYMMDD` | Optional user export | Data about users identified by a User-ID you set. |
Each event row holds the event name, timestamp, user pseudo ID, device and geography fields, traffic source fields, and an event_params array of key-value pairs. Because you read rows directly, you work with unsampled data. Thresholding does not hide rows, and no 14-month Exploration window applies.
Setting up the link
You need the Editor role on the GA4 property and Owner access on the Google Cloud project. In Admin, open Product links, choose BigQuery links, and select Link. Then choose these options:
- Pick the Google Cloud project.
- Pick the data location. This cannot be changed later, so choose it with your residency requirements in mind.
- Pick the data streams to export, and any events to exclude.
- Choose Daily, Streaming, or both. Streaming adds BigQuery streaming-insert costs. The daily export is free to create, though you pay for BigQuery storage and queries.
Standard properties have a daily export limit of 1 million events per day. Properties that exceed it can have daily exports paused. GA4 360 properties have a much higher limit. Check the current documentation for the exact figures, because they have changed over time.
The export is not retroactive
An export starts on the day you link. Events collected before the link are not in BigQuery. Your archive only goes back as far as the link date, so create the link early, ideally when you create the property.
Many teams discover this when they need year-over-year data and find that the link was only added last month. A property with 14 months of GA4 history but a link only 2 months old has 12 months of data that you can see in GA4 but cannot export.
Querying archived history
Daily tables are date-sharded, so you query across them with a wildcard and filter on _TABLE_SUFFIX to limit the bytes scanned and the cost.
SELECT
PARSE_DATE('%Y%m%d', event_date) AS day,
event_name,
COUNT(*) AS events
FROM `my-project.analytics_123456789.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20240101' AND '20240131'
GROUP BY day, event_name
ORDER BY day, events DESC;The wildcard events_* also matches events_intraday_* tables, but the suffix filter above excludes them. A suffix such as intraday_20240131 does not fall between two date strings. If you filter with >= only, add a check that the suffix is purely digits.
Because you query raw rows, your numbers may differ from the GA4 interface. Reasons include different user counting methods, modeled data, and Google signals data that appears only in GA4. Settle on one source of truth for each metric.
Controlling retention inside BigQuery
BigQuery has its own expiry settings, and they can quietly delete your archive:
- A table expiration deletes a table after a set time.
- A dataset's default table expiration applies to newly created tables.
- BigQuery sandbox projects, which have no billing account, apply a default expiration of 60 days to tables.
For an archive, confirm that the dataset has no default expiration, or one that matches your policy. This statement sets a default of three years (1095 days) for new tables in the dataset:
ALTER SCHEMA `my-project.analytics_123456789`
SET OPTIONS (default_table_expiration_days = 1095);A default applies only to tables created after you set it. Tables that already exist keep their current expiration, so check them separately. If your policy is to keep data indefinitely, remove the expiration instead of setting a long one. Also confirm that billing is enabled on the project so the sandbox limit does not apply.
Privacy duties continue in BigQuery
An archive that lasts forever can conflict with your privacy policy. The raw rows contain pseudonymous identifiers, precise timestamps, and approximate location. Treat them as personal data when regulations such as GDPR apply.
Three points follow from this:
- Deletion does not propagate. A data deletion request in GA4 removes data from GA4. It does not remove rows from your BigQuery dataset. You must run your own deletion process there.
- Consent still matters. If consent mode denies
analytics_storage, GA4 does not set analytics cookies. Depending on your setup, the export may contain cookieless pings or no events for that visitor. Check theprivacy_infofields before assuming either. - Access is yours to manage. Anyone with BigQuery access to the dataset can read user-level data. Grant least-privilege roles, such as BigQuery Data Viewer on the dataset, instead of project-wide access.
A reasonable policy sets a BigQuery retention period that you can justify, such as 25 months for year-over-year analysis plus a buffer. It also states who can query the data and how deletion requests reach BigQuery.
Decision criteria
| Question | If yes | If no |
|---|---|---|
| Do you need Exploration-style analysis older than 14 months? | Enable the export, and model that analysis in BigQuery. | Retention alone may suffice. |
| Does your policy demand data minimization? | Set a BigQuery expiration that matches the policy. | Keep the dataset without expiration. |
| Do you need same-day data outside GA4? | Add streaming and budget for it. | Daily export is enough. |
| Do you expect over 1 million events per day on a standard property? | Plan for the daily limit, or consider GA4 360. | Standard limits are fine. |
Common errors
- Assuming the export backfills. It starts on the link date.
- Leaving sandbox expiration in place. Tables disappear after 60 days.
- Treating BigQuery as outside the privacy policy. It holds the most detailed copy of the data.
- Comparing BigQuery totals with GA4 reports and reporting a bug. The two use different counting and processing.
- Forgetting the late data window. Daily tables can be updated for a short time after the day ends, so avoid freezing yesterday's numbers immediately.
Exercise
A property was created 18 months ago. Event data retention is set to 14 months. The BigQuery link was added 5 months ago, and the dataset was created in a sandbox project with no billing account. A colleague says the team is safe because "BigQuery keeps everything." Name two reasons that statement is wrong, and say what you would change.
Show answer
First, the export is not retroactive, so BigQuery holds only the last 5 months of raw events. The earlier 13 months exist only in GA4, where user-level data older than 14 months is being lost. Second, sandbox projects apply a default 60-day table expiration, so even the exported tables are being deleted. Fix it by enabling billing on the project, removing or lengthening the dataset's default table expiration, and checking the expiration on existing tables. Also confirm that the link is active and that the daily export limit is not being hit. Accept that the first 13 months of raw history cannot be recovered into BigQuery.