GA4 BigQuery SQL Generator
Pick your metrics, dimensions and filters, and get readable BigQuery SQL for the GA4 export, explained line by line so you can check it rather than trust it.
Source table and dates
Your GA4 export lives in one table per day. The date range becomes a _TABLE_SUFFIX filter, which is what stops BigQuery reading every day you have ever collected.
Metrics
What you want counted. Every metric here is written the way GA4 itself defines it, including the awkward parts.
Dimensions
What you want to break the metrics down by. Each one becomes a column and a GROUP BY. Choose none and you get one summary row.
Filters
Filter on any dimension, whether or not you are grouping by it. You can also filter on a metric you have selected, which becomes a HAVING clause because it can only be applied after the totals exist.
Sort
Your query
Written for the GA4 BigQuery export schema. Run it in the BigQuery console, or with the bq command line tool. Always dry run first if the date range is long.
Use this tool on your own site
Free to embed, no attribution required, though a credit link is appreciated and included by default. The tool runs entirely in the visitor's browser, so nothing you enter is sent anywhere.