Public dataset · Web, code and analytics
GA4 Sample Ecommerce in BigQuery
The ga4_obfuscated_sample_ecommerce dataset is a Google Analytics 4 BigQuery export from the Google Merchandise Store, obfuscated, covering 1 November 2020 to 31 January 2021. All 92 daily tables add up to 3.3 GiB, so it is the free place to learn GA4 export SQL before you query your own property.
bigquery-public-data.ga4_obfuscated_sample_ecommerce is obfuscated Google Analytics 4 data that emulates a web ecommerce implementation, published by Google so anyone can practice analyzing GA4 data in BigQuery. Google's page for the dataset says it comes from the Google Merchandise Store, an online store selling Google-branded merchandise, and that some fields hold placeholder values such as <Other>, NULL and empty strings. Internal consistency is limited, and the numbers do not match the Google Analytics demo account for the same store.
The layout is the standard GA4 export: one date-sharded table per day, events_YYYYMMDD, with one row per event. Event parameters sit in the repeated event_params record, ecommerce totals in ecommerce, and purchased products in the repeated items record. There are no events_intraday_* tables, and the data was loaded once in August 2021 and does not change.
The GA4 BigQuery cookbook on this site uses this dataset for every recipe, from unnesting event_params to purchases and revenue.
Tables and sizes
The dataset has 92 tables; the main ones are listed.
| Table | Rows | Size | Full scan | Layout |
|---|---|---|---|---|
events_YYYYMMDD92 daily tables, events_20201101 to events_20210131. Rows and size are the total of all 92. | 4,295,584 | 3.3 GiB | $0.02 | None |
Example queries
Event counts for the whole period
Querying all 92 tables through the events_* wildcard is cheap here because only event_name is read.
SELECT event_name, COUNT(*) AS events
FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
GROUP BY event_name
ORDER BY events DESC;All purchase events with SELECT * (expensive)
SELECT * reads every column of every daily table, even though only a small share of rows are purchases. On a real property with years of data, this pattern is what blows up a bill.
SELECT *
FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
WHERE event_name = 'purchase';Orders and revenue for one week
The _TABLE_SUFFIX filter limits the wildcard to seven tables, and only four columns are read. About 300 times fewer bytes than the SELECT * version.
SELECT
PARSE_DATE('%Y%m%d', event_date) AS day,
COUNT(DISTINCT ecommerce.transaction_id) AS orders,
ROUND(SUM(ecommerce.purchase_revenue_in_usd), 2) AS revenue_usd
FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20201201' AND '20201207'
AND event_name = 'purchase'
GROUP BY day
ORDER BY day;Daily users in December 2020
user_pseudo_id identifies a browser or device. It is not a person: one person on two devices counts twice. The GA4 cookbook covers the difference from user_id.
SELECT
PARSE_DATE('%Y%m%d', event_date) AS day,
COUNT(DISTINCT user_pseudo_id) AS users
FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20201201' AND '20201231'
GROUP BY day
ORDER BY day;Most viewed pages in January 2021
Pulls page_location out of event_params with a subquery. The repeated event_params column is the heaviest in the export, which is why this month costs more than the other examples.
SELECT
(SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'page_location') AS page,
COUNT(*) AS page_views
FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20210101' AND '20210131'
AND event_name = 'page_view'
GROUP BY page
ORDER BY page_views DESC
LIMIT 20;Querying it cheaply
- Always add a
_TABLE_SUFFIXrange when you queryevents_*. BigQuery then reads only the matching daily tables. event_paramsanditemsare the heaviest columns. Reference them only in queries that need them; most counts by event, date, device or country never touch them.- The whole dataset is 3.3 GiB, so mistakes here are cheap. The same
SELECT *habits on a production export with years of history can read TiBs. The GA4 cookbook has a recipe on keeping export queries cheap. - The data is static, so identical queries return from the cache at no charge when you run them again.
FAQ
How much does it cost to query the GA4 sample dataset?
Practically nothing. The whole dataset is 3.3 GiB, which is under 1% of the free 1 TiB a month, and typical recipe queries read 10 to 350 MiB. Each query bills at least 10 MB.
Is the GA4 obfuscated sample ecommerce dataset free?
Yes for storage: the data sits in the bigquery-public-data project and Google pays to store it. You pay for the queries you run from your own project. On-demand, the first 1 TiB scanned each month is free, then you pay per TiB scanned (see BigQuery pricing).
What dates does the GA4 sample dataset cover?
92 days, from 2020-11-01 to 2021-01-31, one table per day from events_20201101 to events_20210131.
Will queries written for the GA4 sample run on my own GA4 export?
Yes, after you change the project and dataset name: the schema is the GA4 export schema. Fields added to the export after 2021, such as collected_traffic_source, are not in the sample, and your property may also have events_intraday_* tables.
Related datasets
All public datasets · BigQuery cost queries · Pricing calculator
