Request a demo

GA4 in BigQuery · Ecommerce and conversions

Purchases, revenue and average order value in GA4 BigQuery

GA4 purchase revenue is in ecommerce.purchase_revenue_in_usd (and purchase_revenue in your currency) on purchase events. Sum it per day, count distinct ecommerce.transaction_id for orders, and divide for average order value. It needs no UNNEST and scans little.

Runs on Google's public sample bigquery-public-data.ga4_obfuscated_sample_ecommerce · Scans 70.6 MiB, under $0.01 on-demand · Checked in November 2026

The query

SELECT
  PARSE_DATE('%Y%m%d', event_date)                       AS day,
  COUNT(*)                                               AS purchase_events,
  COUNT(DISTINCT ecommerce.transaction_id)               AS transactions,
  COUNT(DISTINCT user_pseudo_id)                         AS purchasers,
  ROUND(SUM(ecommerce.purchase_revenue_in_usd), 2)       AS revenue_usd,
  ROUND(SAFE_DIVIDE(SUM(ecommerce.purchase_revenue_in_usd),
                    COUNT(DISTINCT ecommerce.transaction_id)), 2) AS avg_order_value_usd
FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20201201' AND '20201231'
  AND event_name = 'purchase'
GROUP BY day
ORDER BY day;

How it works

The ecommerce record holds order-level values for purchase and refund events: purchase_revenue and purchase_revenue_in_usd, tax_value, shipping_value, refund_value (each also in USD), total_item_quantity, unique_items and transaction_id. Google's schema notes that the revenue fields are populated for purchase events only. The _in_usd fields are converted to US dollars; the plain fields are in the currency the tag sent.

The query sums revenue per day and counts distinct transaction IDs as orders. Purchase events and transactions differ when a purchase event fires twice for the same order, which happens with page reloads of a confirmation page. Counting distinct transaction_id protects the order count; to protect the revenue sum too, keep one event per transaction (first variation).

Read the transaction ID from ecommerce.transaction_id, which is a STRING. The transaction_id event parameter in this sample is a string on 4,786 events and an integer on 456, a mix that breaks joins.

Refunds arrive as separate refund events with ecommerce.refund_value. Subtract them for net revenue; the sample has none.

ColumnMeaning
purchase_eventspurchase events that day.
transactionsDistinct ecommerce.transaction_id. Lower than purchase events if purchases were sent twice.
purchasersDistinct users who purchased.
revenue_usdSum of ecommerce.purchase_revenue_in_usd.
avg_order_value_usdRevenue divided by transactions.

Notes and cost

  • Cost: no event_params and no items. The ecommerce record is small (12.6 MiB for the whole sample) and STRUCT fields are read individually, so one month costs 70.6 MiB. Revenue reports are among the cheapest GA4 queries if you keep items out of them.
  • Use _in_usd fields to add up revenue across currencies. Use purchase_revenue only when the property sells in one currency and you want that currency.
  • Purchases can arrive late (offline or delayed hits). Revenue for the last three days can still change; see intraday tables.

Variations

Deduplicate purchase events by transaction_id

Keeps the first event per transaction, so revenue is not counted twice. Uses QUALIFY.

WITH purchases AS (
  SELECT
    event_date,
    event_timestamp,
    ecommerce.transaction_id,
    ecommerce.purchase_revenue_in_usd
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE _TABLE_SUFFIX BETWEEN '20201201' AND '20201231'
    AND event_name = 'purchase'
  QUALIFY ROW_NUMBER() OVER (
    PARTITION BY ecommerce.transaction_id ORDER BY event_timestamp) = 1
)
SELECT
  PARSE_DATE('%Y%m%d', event_date)       AS day,
  COUNT(*)                               AS transactions,
  ROUND(SUM(purchase_revenue_in_usd), 2) AS revenue_usd
FROM purchases
GROUP BY day
ORDER BY day;

Revenue, tax and shipping per month

SELECT
  DATE_TRUNC(PARSE_DATE('%Y%m%d', event_date), MONTH) AS month,
  ROUND(SUM(ecommerce.purchase_revenue_in_usd), 2)    AS revenue_usd,
  ROUND(SUM(ecommerce.tax_value_in_usd), 2)           AS tax_usd,
  ROUND(SUM(ecommerce.shipping_value_in_usd), 2)      AS shipping_usd
FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20201101' AND '20210131'
  AND event_name = 'purchase'
GROUP BY month
ORDER BY month;

FAQ

Where is revenue in the GA4 BigQuery export?

In ecommerce.purchase_revenue_in_usd (USD) and ecommerce.purchase_revenue (your currency) on purchase events. Item-level revenue is in items.item_revenue_in_usd.

Why do purchase events outnumber transactions?

The same order can be sent twice, for example when a confirmation page reloads. Count distinct ecommerce.transaction_id, and deduplicate events before summing revenue.

Does event_value_in_usd equal purchase revenue?

Not necessarily. event_value_in_usd is the event's value parameter converted to USD; purchase_revenue_in_usd is the ecommerce revenue. Use the ecommerce field for revenue reports.

All GA4 export queries · BigQuery cost queries · The GA4 sample dataset

Cut BigQuery spend without guessing

Masthead attributes compute and storage cost to every project, user, pipeline and table, finds unused and dead-end tables, and shows where editions or on-demand pricing is cheaper. Mnemonic cut its BigQuery compute cost by 20% within 24 hours of onboarding.