Cohort Retention Analysis
How to define age-aligned user cohorts, calculate monthly retention in BigQuery, and interpret period versus continuous retention.
Define cohorts and
Define cohorts and
A is a group of users who share a starting event in the same period. For retention analysis, a common choice is to group users by the calendar month of their first activity. Applying the same starting rule consistently makes it clear which users belong to each .
measures time from that starting period, rather than using the calendar date by itself. Age 0 is the ’s starting month; age 1 is the following month. Thus, a January ’s age-1 activity is in February, while a February ’s age-1 activity is in March.
This alignment makes comparisons fairer across groups that began at different times. To compare early follow-up, compare each at age 1—not all cohorts in the same calendar month. The latter would mix users at different stages since their starting activity.
Calculate and interpret monthly retention
Calculate and interpret monthly retention
For a and a given age month, monthly is the number of distinct members active in that month divided by the ’s original size. For example, if 42 of the 100 users in a are active at age 1, the rate is
Count users, not events: if one user generates several events in the same month, that user still contributes only one active user for that month. Likewise, the denominator remains the ’s original size. It is not the number who were active in the previous month.
| Stage | Purpose |
|---|---|
| Date bounds | Set the cohort start and the last complete month. |
| User-month activity | Truncate activity dates to months and keep one row per user per month. |
| Cohort assignment | Use the minimum activity month for each user. |
| Activity by age | Count distinct active users for each cohort and age. |
| Age grid | Generate each age observable for each cohort. |
| Final join | Left-join counts to the grid; use zero where no activity was counted. |
How the query builds the measure
The supplied BigQuery query separates the calculation into stages using common table expressions (CTEs). First, it sets a start date and an “as of” date, then derives the last full month. In the example, the as-of date is June 15, 2025, so the current month is excluded and May is the last complete month.
Next, it converts event timestamps to activity months and deduplicates at the user-and-month level. The query assigns each user a month with a per-user window minimum:
MIN(activity_month) OVER (PARTITION BY user_id)
This gives each user their earliest observed activity month in the data being used. The history must be long enough to capture their true first activity: if earlier activity is missing, or events are filtered to the reporting period before assignment, a returning user can be misclassified as new.
The query then counts distinct active users by month and age. Because activity months are truncated to month starts, DATE_DIFF(activity_month, cohort_month, MONTH) gives the number of whole month steps from the month. size is counted separately, so each age’s active-user count can be divided by the original size.
Finally, the query generates every observable age for each . It left-joins the observed activity counts to this grid and uses COALESCE to show zero when no active users were counted. Without the grid and left join, an age with no observed activity could be absent from the output rather than represented as zero.
Choose and check the measure
counts users active in a particular month even if they were inactive in an earlier month. is stricter: it counts users only if they were active in every preceding period. Choose between them according to the question; they describe different patterns of return and ongoing activity.
Use a consistent timezone when converting timestamps to dates, because timezone boundaries can change which calendar month receives an event. Also compare only ages with complete observation periods. The supplied query excludes the current, potentially incomplete month; date bounds and table names should be adapted to the data and reporting question.