Sub topic 13
Reading the export: datasets, tables, and columns
This chapter explains what the BigQuery link creates in your project and how to read it. It assumes you have already created the link and know basic SQL (SELECT, WHERE, GROUP BY). It also assumes you know what GA4 events and event parameters are. Querying the repeated fields in depth comes in the next chapter. Here you learn the layout so you know where to look.
What the link creates
When you link a GA4 property to BigQuery, GA4 creates one dataset in your Google Cloud project. The dataset is named analytics_ followed by the GA4 property ID. For property 123456789, the dataset is analytics_123456789. The dataset lives in the location you chose when you created the link. You cannot change that location later, so a wrong choice means deleting the link and creating a new one.
Inside the dataset, GA4 creates tables as exports run. Which tables you see depends on the export types you enabled.
| Table | Created by | Contents |
|---|---|---|
| `events_YYYYMMDD` | Daily export | One table per day, with all events for that day. |
| `events_intraday_YYYYMMDD` | Streaming export | Events for the current day, updated continuously. |
| `pseudonymous_users_YYYYMMDD` | User export | One row per pseudonymous user, with user-level properties. |
| `users_YYYYMMDD` | User export | One row per user ID, for users with a user ID set. |
The date in each table name is the date of the events in the property's reporting time zone. The daily export writes a new events_ table once a day. The streaming export writes an events_intraday_ table, which is replaced by the final events_ table after the day completes. This chapter focuses on the events_ tables, since most analysis uses them.
Confirming that tables arrive
The first check is to list the dataset's tables with the bq command-line tool. The first command lists tables. The second limits the output to five.
bq ls --project_id=my-project analytics_123456789
bq ls --project_id=my-project --max_results=5 analytics_123456789After you create the link, the first daily table usually appears within about a day. If the dataset exists but is empty, wait for the first export before troubleshooting.
One row per event
The events_ table has one row for each event. A page_view produces one row, and a purchase produces another. This differs from the GA4 interface, where reports start from sessions and users. In BigQuery you build sessions and users yourself from event rows.
Because each row is an event, the row count is the event count. COUNT(*) with a filter on event_name gives you the number of those events. Counting users or sessions needs COUNT(DISTINCT ...) on the right columns.
The main columns
The export has a fixed set of top-level columns. These are the ones you will use most.
| Column | Type | Meaning |
|---|---|---|
| `event_date` | STRING | Date of the event as `YYYYMMDD`, in the property's time zone. |
| `event_timestamp` | INTEGER | Time the event was logged, in microseconds since the Unix epoch (UTC). |
| `event_name` | STRING | Name of the event, such as `page_view`. |
| `event_params` | RECORD, repeated | Key-value pairs describing the event. |
| `user_pseudo_id` | STRING | Pseudonymous identifier for the browser or app instance. |
| `user_id` | STRING | The ID you set, if you send one. Often null. |
| `user_properties` | RECORD, repeated | Key-value pairs describing the user. |
| `device` | RECORD | Device category, operating system, browser, and similar. |
| `geo` | RECORD | Country, region, and city. |
| `traffic_source` | RECORD | The source, medium, and campaign that first acquired the user. |
| `platform` | STRING | `WEB`, `ANDROID`, or `IOS`. |
| `stream_id` | STRING | ID of the data stream that sent the event. |
Two details cause frequent mistakes.
event_dateis a string, not aDATE. Comparing it to'20250101'works. Comparing it toDATE '2025-01-01'fails unless you convert it withPARSE_DATE('%Y%m%d', event_date).event_timestampis in microseconds. To get a readable timestamp, useTIMESTAMP_MICROS(event_timestamp). Treating the value as seconds or milliseconds gives dates in the wrong century.
The traffic_source column describes where the user was first acquired. It does not describe the source of the current session. For session-level source, you read parameters such as source and medium from event_params on the relevant events. This is one reason acquisition numbers in BigQuery can differ from the GA4 interface.
Records and repeated fields
Some columns are not simple values. BigQuery supports two structures that you need to recognize in the schema.
- A RECORD (also called a STRUCT) groups named fields. You reach inside with dot notation. For example,
device.categoryreturns the device category andgeo.countryreturns the country. - A REPEATED field holds zero or more items in each row.
event_paramsanduser_propertiesare repeated records, so each event row carries a list of key-value pairs.
Each item in event_params has a key and a value. The value is itself a record with four typed fields: string_value, int_value, float_value, and double_value. GA4 fills exactly one of them for each parameter and leaves the others null. You must know which type a parameter uses. The parameter ga_session_id is stored in int_value, while page_location is stored in string_value. Reading the wrong field returns null with no error.
This design stores any parameter without changing the table schema. The cost is that you cannot write WHERE page_location = '...', because page_location is not a column. It is a value inside a list.
Reading a parameter from the list
The standard pattern is a scalar subquery that unnests the list and picks one key. The next query counts daily sessions. It builds a session key from user_pseudo_id and the ga_session_id parameter, because a session ID alone is not unique across users.
SELECT
event_date,
COUNT(DISTINCT CONCAT(
user_pseudo_id, '-',
CAST((SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS STRING)
)) AS sessions
FROM `my-project.analytics_123456789.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20250101' AND '20250131'
GROUP BY event_date
ORDER BY event_date;The subquery SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id' turns the list into temporary rows and keeps the one with the matching key. The outer query then treats the result as a single value. The next chapter covers UNNEST in more detail.
Wildcard tables
The events_* in the table path is a wildcard table. It makes BigQuery treat all matching tables as one. The pseudo-column _TABLE_SUFFIX holds the part of the table name matched by the *. For events_20250115, the suffix is 20250115.
Filtering on _TABLE_SUFFIX limits which tables BigQuery reads, and so limits the data scanned and the cost. A filter on event_date alone does not do this for the wildcard, so always include the _TABLE_SUFFIX condition.
One gotcha: events_* also matches events_intraday_* tables. The suffix of an intraday table starts with intraday_. A range such as BETWEEN '20250101' AND '20250131' excludes those, because the string intraday_20250115 sorts after the digits. If you filter with only a lower bound, such as >= '20250101', intraday tables are included and you may count today's events twice or in a partial state. Always set both bounds.
A second example: top pages
The same pattern works for string parameters. This query ranks the most viewed pages for the month. It reads page_location from string_value and filters to page_view events.
SELECT
(SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'page_location') AS page_location,
COUNT(*) AS page_views
FROM `my-project.analytics_123456789.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20250101' AND '20250131'
AND event_name = 'page_view'
GROUP BY page_location
ORDER BY page_views DESC
LIMIT 20;The page_location value is the full URL, including the query string. Two URLs that differ only by a tracking parameter appear as separate rows. Clean the URL in the query if you want pages grouped by path.
Common errors
- Null results from a parameter. You read the wrong value field. Check which of the four typed fields the parameter uses in the table schema or in a sample row.
- Table not found. The dataset is in a different project or location, or the wildcard has a typo. Run
bq lsto confirm the names. - Yesterday's data is missing. The daily table arrives after the day ends and can be delayed. Use the intraday table if you need current data and the streaming export is on.
- Counts differ from the GA4 interface. The export holds raw events. The interface applies processing, thresholds, and modeling that the export does not. A later chapter covers these differences.
Exercise
A teammate runs SELECT COUNT(*) FROM my-project.analytics123456789.events* WHERE _TABLE_SUFFIX >= '20250101' AND event_name = 'page_view' and gets a higher number than expected for the current month. Name two things in this chapter that could explain the inflated count, and give a corrected filter for January 2025.
Show answer
The filter has no upper bound, so it reads every table from January 2025 onward, including later months. It also matches eventsintraday tables, which hold partial data for the current day and can overlap with the final table. A corrected filter is _TABLE_SUFFIX BETWEEN '20250101' AND '20250131'. The closed range excludes both later months and the intraday tables.
Exercise
You run SELECT event_name, (SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') FROM ... and every value in the second column is null. Why, and how do you fix it?
Show answer
The gasessionid parameter is stored in intvalue, not stringvalue. GA4 fills only one typed field per parameter, so reading stringvalue returns null without an error. Change the subquery to select `value.intvalue`.