Datalad generator

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.

1

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.

2

Metrics

What you want counted. Every metric here is written the way GA4 itself defines it, including the awkward parts.

3

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.

4

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.

FieldOperatorValue
No filters. The query will return every row in the date range.
5

Sort

6

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.

Take your SQL query with you

Enter your email and your SQL query downloads as a file straight away. You will also get new free tools, templates and cheatsheets from Datalad. Unsubscribe anytime.

Share and embed

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.

px

View Comments (4)

Leave a Reply

Subscribe to My Newsletter

Subscribe to my email newsletter to get the latest posts delivered right to your email. Pure inspiration, zero spam.