Skip to content

E-commerce cohorts and retention: seeing past GA4's 14 months

Cohort analysis for e-commerce asks one question: do the customers you recruit come back? GA4's cohort exploration answers it inside a retention window of 14 months at most. The BigQuery export keeps every month you store, so SQL builds the full matrix. This method extends our guide to journeys, baskets, and repeat buyers in GA4.

What does the GA4 cohort exploration really measure?

The GA4 cohort exploration counts, period after period, the users of a group who meet a return criterion. You pick the inclusion criterion: first touch, any event, any transaction, any conversion, or one named event. You pick the return criterion the same way. Granularity is daily, weekly, or monthly, and weekly cohorts run Sunday to Saturday. Each cell is standard, rolling, or cumulative.

Three limits shape what it can tell you. First, the data retention setting applies to explorations. A standard property keeps event data for 2 or 14 months, so older cohorts disappear. Second, the exploration shows at most 60 cohorts, and a breakdown keeps its top 15 values only. Third, it counts users as the interface defines them, with thresholds on demographic dimensions.

The exploration answers "did last quarter's recruits come back?" well. It cannot compare this January's recruits with those of two years ago at the same age. Those events are gone from the interface.

The raw BigQuery export has none of these limits. It stores events, not a report. A cohort is then a query over every month you kept, split by any field.

A cohort is a group of users who share a first-visit period, followed at the same age after that first visit, so that the return rate of one month's recruits can be compared with another's at the same age rather than on the same calendar date.

How do you define the cohort: first visit, first purchase, channel, or market?

Each cohort definition pairs a start event with an optional split, and answers its own question. The first visit tells you whether traffic comes back. The first purchase tells you whether buyers buy again, the core e-commerce question. The first channel and first market tell you which recruits are worth recruiting again.

Cohort keyExport fieldQuestion it answersTrap
First visit monthfirst_visit event, event_dateDo the visitors we recruit come back?A cleared cookie restarts the clock
First purchase monthfirst purchase with a transaction_idDo first-time buyers buy again?A buyer from before the export looks new
First channeltraffic_source.medium, user levelWhich channel recruits visitors who return?Fixed at first acquisition, never updated
First marketgeo.country of the first eventWhich market keeps its recruits?Country is per event: freeze the first one
First touchuser_first_touch_timestampWhen was this cookie first seen, even before the export?Missing on some users

A first-visit cohort inherits the GA4 meaning of a new user.

A new user in GA4 is a user_pseudo_id whose first_visit event occurs in the period: a cookie seen for the first time, not a person, so a cleared cookie or a second device creates a second new user, and the GA4 reports count it on that event.

Our journeys and retention guide counted that population three ways on January 2021. It found 88,873 first_visit events and 88,830 distinct users with one. It also found 90,221 users with a session numbered 1. Which count a model should keep is the subject of New and returning: what "new user" really means in GA4.

The first-purchase cohort on the public sample

The first-purchase cohort follows buyers rather than visitors. The query dates each buyer by their first order month. Then it looks for an order in the next month.

WITH orders AS (
  SELECT DISTINCT user_pseudo_id, ecommerce.transaction_id,
    DATE_TRUNC(PARSE_DATE('%Y%m%d', event_date), MONTH) AS order_month
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE _TABLE_SUFFIX BETWEEN '20201101' AND '20210131'
    AND event_name = 'purchase'
    AND ecommerce.transaction_id IS NOT NULL AND ecommerce.transaction_id != '(not set)'
),
first_order AS (
  SELECT user_pseudo_id, MIN(order_month) AS cohort_month FROM orders GROUP BY user_pseudo_id
)
SELECT
  FORMAT_DATE('%Y-%m', f.cohort_month) AS first_purchase_month,
  COUNT(DISTINCT f.user_pseudo_id) AS buyers,
  COUNT(DISTINCT IF(o.order_month = DATE_ADD(f.cohort_month, INTERVAL 1 MONTH), f.user_pseudo_id, NULL)) AS bought_again_m1,
  ROUND(100 * COUNT(DISTINCT IF(o.order_month = DATE_ADD(f.cohort_month, INTERVAL 1 MONTH), f.user_pseudo_id, NULL)) / COUNT(DISTINCT f.user_pseudo_id), 1) AS bought_again_m1_pct
FROM first_order f
JOIN orders o USING (user_pseudo_id)
-- January buyers have no observable next month in the sample
WHERE f.cohort_month <= '2020-12-01'
GROUP BY first_purchase_month
ORDER BY first_purchase_month
Cohort (month of first purchase)BuyersBought again in M+1
2020-111,11377 (6.9%)
2020-121,82837 (2.0%)

Computed on 2026-10-15 on the public sample bigquery-public-data.ga4_obfuscated_sample_ecommerce (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data).

December recruited more buyers, and far fewer of them bought again in January. On a real store, that gap is the question to ask after every peak. One caution: "first purchase" means first within the tables. A customer who bought in October 2020 counts here as a November recruit.

SQL: cohort size and return at M+1, M+3, and M+6

A retention matrix takes three steps: cohort month, active months, and the age between them. The function DATE_TRUNC brings each date to its month. The function DATE_DIFF in months gives the age. The cohort month is age 0, the next one age 1.

A retention matrix is a table with one row per cohort and one column per age, where each cell gives the share of the cohort active at that age, and where an age the cohort has not reached yet stays empty.

The last clause matters most. A November cohort cannot be active in May if the tables stop in January. The query returns NULL for those cells. A chart then shows a gap, not a false fall to zero.

WITH first_seen AS (
  SELECT user_pseudo_id, DATE_TRUNC(MIN(PARSE_DATE('%Y%m%d', event_date)), MONTH) AS cohort_month
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE _TABLE_SUFFIX BETWEEN '20201101' AND '20210131'
    AND event_name = 'first_visit'
  GROUP BY user_pseudo_id
),
activity AS (
  SELECT DISTINCT user_pseudo_id, DATE_TRUNC(PARSE_DATE('%Y%m%d', event_date), MONTH) AS active_month
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE _TABLE_SUFFIX BETWEEN '20201101' AND '20210131'
),
counts AS (
  SELECT f.cohort_month, DATE_DIFF(a.active_month, f.cohort_month, MONTH) AS month_number,
    COUNT(DISTINCT f.user_pseudo_id) AS users
  FROM first_seen f
  JOIN activity a ON a.user_pseudo_id = f.user_pseudo_id AND a.active_month >= f.cohort_month
  GROUP BY 1, 2
),
ages AS (SELECT * FROM UNNEST([1, 2, 3, 6]) AS age)
SELECT
  FORMAT_DATE('%Y-%m', c0.cohort_month) AS cohort,
  c0.users AS new_users,
  g.age AS month_number,
  -- NULL = the cohort has not reached that age in the data; 0 would be a false zero
  IF(DATE_ADD(c0.cohort_month, INTERVAL g.age MONTH) > '2021-01-01', NULL, IFNULL(ck.users, 0)) AS active_users,
  IF(DATE_ADD(c0.cohort_month, INTERVAL g.age MONTH) > '2021-01-01', NULL,
     ROUND(100 * IFNULL(ck.users, 0) / c0.users, 1)) AS retention_pct
FROM counts c0
CROSS JOIN ages g
LEFT JOIN counts ck ON ck.cohort_month = c0.cohort_month AND ck.month_number = g.age
WHERE c0.month_number = 0
ORDER BY cohort, month_number
Cohort (month of first visit)New usersM+1M+2M+3M+6
2020-1171,7343,254 (4.5%)675 (0.9%)not reachednot reached
2020-1296,7642,252 (2.3%)not reachednot reachednot reached
2021-0188,816not reachednot reachednot reachednot reached

Computed on 2026-10-15 on the public sample bigquery-public-data.ga4_obfuscated_sample_ecommerce (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data).

The sample covers three months, so M+3 and M+6 stay empty for every cohort. On your own export, the same query fills them once the tables cover that age. The cohort sizes match our journeys and retention guide: 71,734 and 96,764 new users. January holds 88,816, that is 14 fewer than its 88,830 users with a first_visit. Those 14 had already fired one in November or December.

Calendar months are easy to read but mix ages. M+1 means one day for a November 30 recruit, and 30 days for a November 1 recruit. Day windows therefore give other rates on the same November cohort. It was 9.8% back on days 1 to 7, and 4.9% on days 8 to 30. Use day windows to measure, and calendar months to report.

Every return rate in this article is a floor, because user_pseudo_id identifies a browser cookie, not a customer. When one person holds several cookies, their return lands on a new cookie. The first cohort never sees it, and a later cohort counts a "new" user who is not.

CauseWhat happens in the cohortEffect on the matrix
Cleared cookiesThe returning visitor becomes a new userReturn rate too low, later cohorts too large
Second deviceThe same person starts a second cohortReturn rate too low
Browser that shortens cookie lifetimeReturns after expiry restart the clockLong ages hit hardest
Consent refused on the return visitNo identifiable cookie to attach the return toReturn rate too low
user_id sent at sign-inCookies of one signed-in customer can be joinedFloor rises toward the true rate

The gap tends to widen with age. A cookie has more time to be cleared or to expire. So M+6 is understated more than M+1. Comparisons between channels or markets remain sound when the bias hits each group alike. Comparisons between ages of one cohort need that caution.

Two joins raise the floor. GA4's User-ID feature connects one user's behavior across sessions and devices. Google requires that the ID contain nothing a third party could use to identify the person. It also applies only from the day you send it. The second join uses transaction_id against your back-office orders, which carry a customer number.

How do you read a retention curve?

A retention curve is read at equal age across cohorts, never along the calendar. On the sample, November recruits came back at 4.5% in M+1, December recruits at 2.3%. December was larger and recruited during the gift season. Visitors recruited at a peak often come once.

Three readings matter. The shape: a steep fall after month 0, then a flattening. The level where it flattens is your loyal core. The comparison: two cohorts at the same age, as in the November and December rows. The volume: 3,254 returning users from November against 2,252 from December. A lower rate on a larger cohort can still bring back many people.

A split by first channel shows which source recruits visitors who return. The query keeps the November cohort and reads its M+1.

WITH first_seen AS (
  SELECT user_pseudo_id,
    DATE_TRUNC(MIN(PARSE_DATE('%Y%m%d', event_date)), MONTH) AS cohort_month,
    ARRAY_AGG(traffic_source.medium ORDER BY event_timestamp LIMIT 1)[OFFSET(0)] AS first_medium
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE _TABLE_SUFFIX BETWEEN '20201101' AND '20210131'
    AND event_name = 'first_visit'
  GROUP BY user_pseudo_id
),
activity AS (
  SELECT DISTINCT user_pseudo_id, DATE_TRUNC(PARSE_DATE('%Y%m%d', event_date), MONTH) AS active_month
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE _TABLE_SUFFIX BETWEEN '20201101' AND '20210131'
)
SELECT
  f.first_medium,
  COUNT(DISTINCT f.user_pseudo_id) AS new_users,
  COUNT(DISTINCT IF(a.active_month = DATE_ADD(f.cohort_month, INTERVAL 1 MONTH), f.user_pseudo_id, NULL)) AS active_m1,
  ROUND(100 * COUNT(DISTINCT IF(a.active_month = DATE_ADD(f.cohort_month, INTERVAL 1 MONTH), f.user_pseudo_id, NULL)) / COUNT(DISTINCT f.user_pseudo_id), 1) AS m1_pct
FROM first_seen f
LEFT JOIN activity a ON a.user_pseudo_id = f.user_pseudo_id
WHERE f.cohort_month = '2020-11-01'
GROUP BY f.first_medium
ORDER BY new_users DESC
First medium, November 2020 cohortNew usersActive in M+1
organic27,5761,246 (4.5%)
(none)17,039787 (4.6%)
<Other>12,989556 (4.3%)
referral10,182462 (4.5%)
cpc3,941202 (5.1%)
(data deleted)71 (14.3%)

Computed on 2026-10-15 on the public sample bigquery-public-data.ga4_obfuscated_sample_ecommerce (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data).

The spread is narrow on the sample: 4.3% to 5.1% across the five main mediums. The last row is the lesson: one user out of seven gives 14.3%, which means nothing. Set a minimum cohort size before you rank anything. Adding revenue to the same matrix turns it into a value curve per channel, the subject of Lifetime value by acquisition channel: the budget question last click never asks.

How much history does a cohort analysis need?

A cohort analysis needs the age you read plus the cohort month, and twice that to compare years. Reading M+6 takes seven months of tables from the cohort's first day. Comparing M+12 with the same cohort a year before takes 25 months.

What you want to readMonths of tables from the cohort's first month
Retention at M+12
Retention at M+67
Retention at M+1213
M+12, one cohort against the same month a year before25

The last two rows sit near or past the 14-month limit of explorations on a standard property. The export has no such limit, but it has no backfill either. It starts on the day you link it. The case for linking it early is made in GA4 data retention: 14 months, and no BigQuery backfill.

The public sample shows what a short history hides. The query dates the users active in January 2021 by user_first_touch_timestamp.

WITH jan_users AS (
  SELECT user_pseudo_id, MIN(user_first_touch_timestamp) AS first_touch_us
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE _TABLE_SUFFIX BETWEEN '20210101' AND '20210131'
  GROUP BY user_pseudo_id
)
SELECT
  CASE
    WHEN first_touch_us IS NULL THEN 'no first touch'
    WHEN DATE(TIMESTAMP_MICROS(first_touch_us)) < '2020-11-01' THEN 'before 2020-11'
    ELSE FORMAT_DATE('%Y-%m', DATE(TIMESTAMP_MICROS(first_touch_us)))
  END AS first_touch_month,
  COUNT(*) AS users_active_in_january,
  ROUND(100 * COUNT(*) / SUM(COUNT(*)) OVER (), 1) AS share_pct
FROM jan_users
GROUP BY first_touch_month
ORDER BY first_touch_month
First touchUsers active in January 2021Share
Before 2020-111,4101.5%
2020-116800.7%
2020-122,2562.4%
2021-0188,80693.7%
No first touch1,6381.7%

Computed on 2026-10-15 on the public sample bigquery-public-data.ga4_obfuscated_sample_ecommerce (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data).

The 1,410 users first seen before November 2020 belong to cohorts older than the tables. A first_visit cohort cannot place them; user_first_touch_timestamp can. The 1,638 users without a first touch need an explicit bucket, not a silent drop.

FAQ

What is a good retention rate for an online store?

No single retention rate is good for every store. It depends on purchase frequency, basket size, and how you define a return. Compare your own cohorts at the same age instead. The public sample figures, 4.5% at M+1 for November 2020, describe one obfuscated store over three months. They illustrate the method and are not a benchmark.

Can GA4 build cohorts on the first purchase?

Yes, GA4 can build first-purchase cohorts, within its data retention window. The cohort exploration accepts "any transaction" as inclusion criterion and as return criterion. It then shows buyers who bought again, period by period. It stays limited to 60 cohorts and to the event data GA4 still keeps. The export gives the same cohort over every month you stored.

Why doesn't my BigQuery cohort table match the GA4 exploration?

The two tools rarely share the same definitions. GA4 weeks run Sunday to Saturday, and its active users follow the interface's own rules. Thresholds can hide small groups, and the property time zone shifts dates. A matching table needs the same start event, return event, period, and time zone on both sides.

Should cohorts be weekly or monthly?

Weekly cohorts suit fast-moving stores and campaign tests: a result arrives within a few weeks. Monthly cohorts suit board reporting and products bought a few times a year. A weekly matrix grows four times faster, so it needs a minimum cohort size before any reading. Both come from the same query with a different truncation.

The journey, basket, and segment methods that complete this one are gathered in Journeys, baskets, and repeat buyers: the e-commerce analyses GA4 doesn't show. To receive the next method when it ships: Get new analyses as they ship.

Sources