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.

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

Add a Comment

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.

Discover more from Discuss Data Science, Machine Learning and Analytics

Subscribe now to keep reading and get access to the full archive.

Continue reading