Retention: Did They Come Back?
Five cats and one calendar
Retention answers a question that neither DAU nor a can answer: did the same people come back?
To answer it, you need a —a group of users who share the same starting condition. In this lesson, the condition is the date of the first visit: for example, “everyone whose first visit was March 1.” A user enters this cohort once and stays in it for the entire observation period.
Here are five cats from the black box, along with the dates of their first visits and all later visits:
| cat | first visit | later visits |
|---|---|---|
| Leo | March 1 | March 2, March 8 |
| Snowball | March 1 | — |
| Fluffy | March 2 | March 3, March 9 |
| Molly | March 5 | March 6 |
| Ginger | March 5 | March 12 |
Calendar dates make these cats hard to compare because each one started using the product on a different day. The comparison becomes useful when we switch from absolute dates to how long each user has been in the product.

Calendar → relative days
D0 is the day of the first visit. It does not mean “day zero of the month”; it means “day zero for THIS user.” Leo's D0 is March 1, while Molly's is March 5. From there, we count each user's days from their own D0.
The table marks only the dates when each cat visited. A dash means there was no visit that day.
| cat | March 1 | March 2 | March 3 | March 5 | March 6 | March 8 | March 9 | March 12 |
|---|---|---|---|---|---|---|---|---|
| Leo | D0 | D1 | — | — | — | D7 | — | — |
| Snowball | D0 | — | — | — | — | — | — | — |
| Fluffy | — | D0 | D1 | — | — | — | D7 | — |
| Molly | — | — | — | D0 | D1 | — | — | — |
| Ginger | — | — | — | D0 | — | — | — | D7 |
The same D1 falls on different calendar dates for different cats: March 2 for Leo and March 6 for Molly. The reverse is also true: March 8 is D7 for Leo but D3 for Molly, even though Molly did not visit that day. This conversion is the key idea behind : we align everyone by their own starting point and can then compare people who arrived on different dates.
Why not simply compare “how many users we had yesterday” with “how many we have today”? Total DAU mixes old and new users together. A product could lose every new user within a week and still grow in DAU if advertising brings in new users faster than old ones leave. Cohort analysis separates one specific group from the overall flow and lets us ask: did these cats come back?
The denominator is the original cohort
Now we'll calculate for our five cats.
The March 1 contains Leo and Snowball, so its size is 2. On D1, only Leo came back → D1 retention = 1 / 2 = 50%. On D7, only Leo came back again → D7 = 50%.
The March 5 cohort contains Molly and Ginger, so its size is 2. Molly came back on D1 → 50%. Ginger came back on D7 → 50%. Notice that these are different cats. Retention does not require the same person to return at every checkpoint: each checkpoint measures its own share of the same original cohort.
At real-world scale, it looks like this:
Cohort 'arrived March 1': 1000 cats ← DENOMINATOR for every checkpoint
active March 2 (D1): 380 → D1 = 380 / 1000 = 38%
active March 8 (D7): 190 → D7 = 190 / 1000 = 19%
active March 31 (D30): 90 → D30 = 90 / 1000 = 9%
This is the rule behind many incorrect retention calculations:
The denominator is always the original cohort—the same 1000 people—not however many are left.
You might be tempted to divide the 190 users active on D7 by the 380 active on D1, which gives 50%. But that number cannot be interpreted as “half of the users who returned on D1 also returned on D7”: these totals do not tell us how many cats were active on both days. To calculate that share, the numerator would need to be the number of cats active on both D1 and D7, and the denominator would be the 380 cats active on D1. That is a different metric, and we do not have the data to calculate it here. Regular D7 retention is still 190 / 1000 = 19%.
A fixed denominator has another consequence: retention at individual daily checkpoints does not have to decrease monotonically. Someone can skip D1 and return on D7, as Ginger did. D7 can therefore be slightly higher than D3, especially if day seven falls on a weekend or coincides with a messaging campaign. A always decreases; this kind of retention does not.
Two decisions to make before you calculate
Decision 1: what does “came back” mean?
As with “active” in the DAU lesson, the phrase “came back” does not define a metric by itself. For the same March 1 :
| definition of “came back” | returned on D1 | D1 |
|---|---|---|
| any event in the log | 452 | 45.2% |
opened the app (app_open) | 380 | 38.0% |
placed an order (purchase) | 61 | 6.1% |
The values differ by more than sevenfold, and all three definitions are valid. For a game, opening the app can be a sensible definition of a return. For a marketplace, you might choose an order if you want to track purchases after the first visit, or an app open if you are studying regular product usage. An order is more closely tied to revenue but happens less often. Choose the definition deliberately, document it, and do not change it without saying so.
Decision 2: “exactly on day N” or “on day N or later”
These are two different kinds of retention, and they produce different numbers.
Exact-day (classic) retention. D7 is the share of the cohort that was active exactly on the seventh day. This is a strict, sensitive metric: if someone visited on D6 and D8 but skipped D7, they do not count toward D7 retention. It works well for comparing cohorts and is common in mobile analytics. Throughout this course, DN always means this type of retention.
Rolling (unbounded) retention. D7 is the share of the cohort that had activity on the seventh day OR later. This definition answers “is this person still around?” rather than “did they visit on one specific day?” Its value is never lower than exact-day retention and usually changes more smoothly. Rolling retention also depends on when the data is collected: if someone comes back later, a previously calculated value can increase.
March 1 cohort, cat visited on March 2 and March 9
exact-day D7 (March 8): NOT counted — the cat was absent that day
rolling D7: counted — March 9 is later than day seven
Neither type is “more correct.” You need to know which one a report uses and avoid comparing the two as if they were the same metric. If D7 differs twofold between two reports, check the retention definition before looking for a change in the product.
Immature cohorts: an empty cell is not zero
Today is March 14. Consider two .
February 1 cohort. In the year 2184, February has 29 days, so this cohort's D30 falls on March 2. That day has already passed, the data has been collected, and the value is known.
March 10 cohort. Its D1 (March 11) is known. Its D7 falls on March 17, and that day hasn't happened yet. Its D30 falls on April 9.
D1 D7 D30
February 1 41% 22% 11%
March 10 39% ? ? ← not reached yet
The question mark is not zero. Zero would mean “nobody came back,” which would be a disaster. Here it means “we don't know yet”: the cohort is immature because not enough calendar time has passed.
In tables and code, this kind of “unknown” value is usually represented by a special value. In pandas, that's NaN (not a number), and we'll cover it in detail in the chapter on dirty data. For now, remember this rule:
NaN ≠ 0. You can't replace an unknown value with zero: skip it or handle it separately in calculations, and leave a gap in a chart instead of drawing a drop to zero.
Here's what can go wrong in practice. If you calculate average D7 across all cohorts and replace immature values with zeros, the average will drop sharply and create a “ decline” that does not exist. If you replace empty D30 values with zeros before plotting a line, the line will fall toward the most recent dates simply because those cohorts do not have D30 data yet.
Investigator's rule: when comparing cohorts, include only those that have reached the age you're measuring. Want to compare D30? Look only at cohorts at least 30 days old and leave the rest blank. For an earlier signal without trying to predict the future, use D1, D3, or D7 if those checkpoints have already matured for every cohort in the comparison. They can reveal changes sooner, but they do not replace D30.
d1 and d7 as percentages. Watch the denominator: it is the same at both checkpoints.survival_d1_to_d7—the share of D1 returners who made it to D7—and churned_by_d7—the number of cats from the ORIGINAL cohort who were not active on D7.Key takeaways
- a is a group of users with the same first-visit day; each user enters it once and stays in it forever
- D0 is the day of a specific user's first visit; calendar dates are converted into user age, so different users are aligned by their own starting points
- the denominator in is always the size of the original cohort; 190 / 380 without data on the overlap between users active on D1 and D7 is just a ratio of two , not D7 retention
- “came back” must be defined in advance: any event, an app open, or an order will produce different results
- exact-day DN (“exactly on day N”) and rolling DN (“on day N or later”) are different metrics; you can't directly compare them as if they were the same metric
- immature cohorts stay empty:
NaN≠ 0
Next up: the cohort table—how all these rows fit into a single grid and what to look at first.