Unlock the power of Google Analytics with Big Query

How to Measure and Analyze Cart Abandonment with GA4 and BigQuery

Cart abandonment kills revenue. But with GA4 and BigQuery, you can do more than just spot it—you can uncover when users come back naturally, and when to target them effectively to win them back.

Yesterday, we tackled Calculating Conversion Rates at Each Step of the Ecommerce Funnel Using BigQuery SQL.
Today, let’s focus on cart abandoners—identifying them and digging into their recovery behavior using a real-world use case and application.

Here’s how we’ll structure today’s deep dive:

  1. Identify cart abandoners
  2. Segment them using dimensions
  3. Measure their natural recovery time
  4. Use timing insights for smarter re-engagement

1. Define Cart Abandoners

Cart abandonment occurs when a user:

Here’s how to surface those users:

WITH
cart_events AS (
  SELECT
    user_pseudo_id,
    MIN(TIMESTAMP_MICROS(event_timestamp)) AS first_add_to_cart
  FROM `your_project.analytics_XXXX.events_*`
  WHERE event_name = 'add_to_cart'
  GROUP BY user_pseudo_id
),
purchase_events AS (
  SELECT
    user_pseudo_id,
    MIN(TIMESTAMP_MICROS(event_timestamp)) AS first_purchase
  FROM `your_project.analytics_XXXX.events_*`
  WHERE event_name = 'purchase'
  GROUP BY user_pseudo_id
)
SELECT
  c.user_pseudo_id,
  c.first_add_to_cart
FROM cart_events c
LEFT JOIN purchase_events p
  ON c.user_pseudo_id = p.user_pseudo_id
  AND p.first_purchase > c.first_add_to_cart
WHERE p.first_purchase IS NULL;

Pointers:

2. Segmenting Abandoners for Deeper Insight

Next: enrich this list by joining in dimensions like traffic source, device, or item category:

SELECT
  c.user_pseudo_id,
  ts.source AS traffic_source,
  i.item_category,
  COUNT(*) AS abandon_count
FROM cart_events c
LEFT JOIN purchase_events p
  ON c.user_pseudo_id = p.user_pseudo_id
  AND p.first_purchase > c.first_add_to_cart
JOIN `your_project.analytics_XXXX.events_*` e
  ON c.user_pseudo_id = e.user_pseudo_id
LEFT JOIN UNNEST(e.event_params) AS param
  ON param.key = 'item_category'
WHERE p.first_purchase IS NULL
GROUP BY c.user_pseudo_id, traffic_source, item_category;

Tips:


3. Measuring Natural Recovery Time (Deepened with GA4BigQuery Insights)

Here’s where things get interesting. According to GA4 BigQuery’s tutorial “Analyze the Recovery Time of Checkout Abandoners”, tracking the time interval between abandonment and eventual purchase lets you determine:

Here’s an adapted SQL approach:

WITH events AS (
  SELECT
    user_pseudo_id,
    event_name,
    TIMESTAMP_MICROS(event_timestamp) AS ts
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE event_name IN ('add_to_cart', 'purchase')
),

first_action AS (
  SELECT
    user_pseudo_id,
    MIN(ts) FILTER (WHERE event_name = 'add_to_cart') AS t_cart,
    MIN(ts) FILTER (WHERE event_name = 'purchase') AS t_purchase
  FROM events
  GROUP BY user_pseudo_id
)

SELECT
  *,
  TIMESTAMP_DIFF(t_purchase, t_cart, HOUR) AS hours_to_recovery
FROM first_action
WHERE t_purchase IS NOT NULL;

Key points:


4. Using Timing Insights for Smarter Re-Engagement

With recovery timing mapped, you can structure interventions:

Time Since AbandonmentAction
<2 hoursGentle reminder: “You left something in your cart.”
24 hoursConsider gentle discount or support offer.
>48 hoursLast push: “Still interested? Here’s 10% off.”

This approach lets you stay relevant without being intrusive — respecting natural recovery while gently nudging users where needed.


5. References & Further Reading


TL;DR

Discover more from GA4 BigQuery

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

Continue reading