GA4 BigQuery Query Generator
Generate BigQuery SQL for your GA4 data
Select your GA4 event, dimensions, metrics, date range, and filters to generate ready-to-run BigQuery SQL. Stop spending hours writing queries from scratch โ get the correct GA4 table schema automatically.
How It Works
Select your event and dimensions
Choose the GA4 event name and the dimensions you want to analyse (page, device, country, etc.).
Set date range and filters
Enter your GA4 BigQuery project/dataset and select the date range for your query.
Copy the SQL
Get ready-to-run BigQuery standard SQL that queries the correct GA4 table schema.
Frequently Asked Questions
Why GA4 Analysts Use BigQuery Instead of the GA4 UI
The GA4 UI is designed for marketers who need quick insights from pre-aggregated reports. But when you need to answer questions like "what is the exact sequence of events that leads to purchase?" or "which specific products were viewed by users who returned within 7 days?", the GA4 UI hits its limit. BigQuery gives you direct access to every individual event, every parameter value, and every user session โ at the raw row level โ with the full power of standard SQL. This GA4 BigQuery query generator produces syntactically correct BigQuery SQL for the most common GA4 analysis patterns, handling the notoriously tricky UNNEST(event_params) syntax automatically.
Understanding the GA4 BigQuery Schema
The GA4 BigQuery export uses a nested, repeated schema โ very different from a standard relational database. Understanding this schema is essential for writing correct queries:
- One row = one event. Every event fired by every user gets its own row. A session with 50 page views creates 50+ rows. Events are not pre-aggregated โ you count, sum, and group them yourself in SQL.
- event_params is a REPEATED RECORD. Each event can have many parameters, stored as an array of
{key, value}structs. To access a specific parameter, you mustUNNEST(event_params)and filter by key. For example, to get the page path:UNNEST(event_params) AS ep WHERE ep.key = 'page_location'. - Values are typed. Each parameter value has four sub-fields:
value.string_value,value.int_value,value.float_value, andvalue.double_value. Only one will be non-null for any given parameter โ useCOALESCE(ep.value.string_value, CAST(ep.value.int_value AS STRING))when the type is uncertain. - Wildcard tables for date ranges. Daily export tables are named
events_YYYYMMDD. Query multiple days withevents_*andWHERE _TABLE_SUFFIX BETWEEN '20240101' AND '20240131'. The_TABLE_SUFFIXpseudo-column is automatically available in wildcard queries.
GA4 BigQuery Query Patterns You'll Use Every Day
Three query patterns cover the vast majority of GA4 BigQuery analysis work:
- Event count by dimension โ count how many times a specific event fired, grouped by a dimension (page, device, country). Core of any traffic or engagement analysis. The generator produces this pattern when you select an event with group-by dimensions.
- Funnel analysis with session-level joins โ identify which users completed step A but not step B in the same session. Requires self-joining the events table on
user_pseudo_idandga_session_idโ the generator handles this join for checkout funnel queries. - Revenue and ecommerce analysis โ sum
purchaseevent values, count uniquetransaction_ids, and compute average order value. These queries access theitemsnested record in addition toevent_paramsโ a secondUNNEST(items)call is required to get item-level data.
Need Expert Tracking Setup?
Our team implements GA4, GTM, and conversion tracking for 200+ clients worldwide. Get a free audit.
Get a Free Consultation โ