Unlock the power of Google Analytics with Big Query

How to Query GA4 Ecommerce Events in BigQuery to Analyze Your Checkout Funnel

Understanding your e-commerce checkout funnel is key to improving conversions and sales. Google Analytics 4 (GA4) exports detailed event-level data to BigQuery. This lets you slice and dice every user interaction in your funnel. These interactions range from product views to purchases. In this post, I’ll walk you through the GA4 e-commerce event schema in BigQuery. I will show you how to write SQL queries to extract the main funnel stages. These stages include view_item, add_to_cart, begin_checkout, and purchase.

By the end, you’ll have a solid foundation to build your own funnel analysis. This will help you unlock deeper insights about your customers’ behavior.


GA4 Ecommerce Events Overview

GA4 tracks ecommerce activity using several key events. Here are the main ones involved in the checkout funnel:

Event NameDescription
view_itemUser views a product detail page
add_to_cartUser adds a product to their shopping cart
begin_checkoutUser starts the checkout process
purchaseUser completes a purchase

Each event is stored in the BigQuery table as a row in events_*. It includes details in nested fields such as event_params, items, and user/session identifiers.


Understanding the GA4 BigQuery Schema

Your GA4 dataset in BigQuery typically looks like this:

To analyze the funnel, we need to filter by these event names and extract relevant parameters.

Find schema documentation here for items in bigquery GA4: Data Export Items Schema


Basic SQL Query to Extract Funnel Events

Here’s a simple example to get started. This query pulls user events for a specific date range and extracts the ecommerce funnel stages with product info:

SELECT
  user_pseudo_id,
  event_name,
  TIMESTAMP_MICROS(event_timestamp) AS event_time,
  (SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'item_name') AS product_name,
  (SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'quantity') AS quantity
FROM
  `your_project.your_dataset.events_*`
WHERE
  event_name IN ('view_item', 'add_to_cart', 'begin_checkout', 'purchase')
  AND _TABLE_SUFFIX BETWEEN '20230801' AND '20230807'
ORDER BY
  user_pseudo_id, event_time
LIMIT 1000;

Explanation:


Next Steps

With this foundation, we can:


TL;DR

Discover more from GA4 BigQuery

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

Continue reading