Coderhouse goes global

🌍

Read more

What Is Cohort Analysis and Why Data Teams Track Retention by Group

AI Engineering

Build and ship real applications with LLMs, agents and automation.

8 weeks · Live online · View course →

Data Analytics

Go from zero to job-ready analyst with SQL, Python and BI tools.

10 weeks · Live online · View course →

Dan Patiño

AI Strategy & Innovation at Coderhouse

Data

What Is Cohort Analysis and Why Data Teams Track Retention by Group

What Is Cohort Analysis and Why Data Teams Track Retention by Group

Cohort analysis is a way of studying data by grouping people (customers, users, students, accounts) according to a shared starting event and a shared time window, then tracking how each group behaves over time. The most common version groups users by the week or month they signed up and asks a simple question: of the people who joined in March, how many were still active one, two, and three months later?

Why it matters now: most digital businesses run on recurring behavior, whether that is a subscription renewal, a repeat purchase, or a weekly login. Topline metrics such as total active users can keep growing while the product quietly gets worse, because new signups hide the people who leave. Cohort analysis separates those effects. It is one of the first techniques product, marketing, and data teams reach for when they need to know whether a change actually improved retention, and it is a staple of data analyst interviews.

How cohort analysis works

Every cohort analysis has three ingredients:

  • A cohort definition: the event that puts someone in a group, such as first purchase, account creation, or first lesson completed, plus the time bucket (day, week, month).

  • A return or outcome event: what counts as “still here.” It might be any login, a second purchase, or a paid renewal.

  • A time axis relative to the start: week 0, week 1, week 2, and so on, counted from each person’s own starting point rather than from the calendar.

The result is usually shown as a retention table (often called a cohort triangle): each row is a cohort, each column is a period since the start, and each cell is the share of the cohort that came back in that period. Product analytics tools build this chart out of the box; see how Mixpanel’s retention report and Amplitude’s Retention Analysis chart define cohorts and return events.

Types of cohorts

Acquisition cohorts

Users are grouped by when they joined. This is the classic retention view and the best way to see whether newer cohorts retain better than older ones after product or onboarding changes.

Behavioral cohorts

Users are grouped by something they did, such as “used the search feature in their first week” or “invited a teammate.” Comparing behavioral cohorts helps teams find the actions that correlate with long-term retention. Amplitude describes this approach in its guide to using cohorts to improve retention.

Attribute cohorts

Users are grouped by a fixed property such as acquisition channel, country, plan, or device. This answers questions like “do customers from paid search churn faster than customers from referrals?”

Reading a cohort table

A few patterns show up again and again:

  • Read down a column to compare cohorts at the same age. If month-3 retention rises for newer cohorts, something you changed is working.

  • Read across a row to see one cohort’s decay curve. A curve that flattens means you have found a group of users who stay; a curve that keeps falling toward zero signals a product-market fit or value problem.

  • Read diagonals to spot calendar effects. A dip that hits every cohort in the same calendar month usually points to an outage, a pricing change, or seasonality rather than to cohort quality.

Building a cohort analysis in SQL

You do not need a specialized tool. With an events or orders table, a typical query has three steps:

  1. Find each user’s cohort: the minimum signup or first-order date, truncated to the week or month.

  2. Join every later activity back to that cohort and compute the period number, such as the number of months between the cohort month and the activity month.

  3. Count distinct active users per cohort and period, then divide by the cohort size to get retention rates.

Clean inputs matter more than clever SQL. Duplicate users, test accounts, and inconsistent timestamps all distort retention curves, so it pays to fix them first; our guide to data cleaning in Python with pandas walks through the usual problems. If your warehouse uses a dimensional model, cohort attributes like channel or plan typically live in a user dimension, which we cover in what a star schema is.

Common mistakes

  • Using calendar periods instead of relative periods. Retention should be measured from each user’s own start date.

  • Counting incomplete periods. The newest cohorts have not lived long enough to fill later columns; leave those cells empty instead of showing zero.

  • Tiny cohorts. A cohort of 40 users can swing wildly. Use larger time buckets or show the cohort size next to each row.

  • Vague return events. “Opened the app” and “completed a purchase” tell very different stories. Pick the event that reflects real value.

  • Confusing correlation with cause. A behavioral cohort that retains better may simply contain more motivated users. Confirm with an experiment before you redesign onboarding around it.

Where cohort analysis is used

Subscription and SaaS companies use it to forecast churn and revenue. E-commerce teams track repeat-purchase rates by first-order month. Marketing teams compare the long-term value of customers from different channels instead of judging campaigns only on first-week conversions. Education platforms use it to see how many students who start a course in a given month are still active weeks later.

FAQ

Is cohort analysis the same as segmentation?

Not quite. Segmentation splits users by any attribute at a point in time. Cohort analysis adds a shared starting event and follows each group across time, which is what makes it useful for retention.

What is a good retention rate?

It depends heavily on the product, the business model, and how you define the return event. The most useful benchmark is your own history: are newer cohorts retaining better than older ones?

Which tools do I need?

SQL and a spreadsheet are enough to start. Product analytics platforms automate the charts, and Python with pandas is handy for custom periods and visualizations.

Want to turn raw events into retention insights and decisions? Explore these Coderhouse courses:

Dan Patiño

I'm Dan Patiño, head of AI Strategy & Innovation at Coderhouse. My day-to-day work involves merging the tactical management of e-commerce (CRO, Email Marketing and SEO) with the development of disruptive solutions. I specialize in building internal AI-powered apps to automate tasks and boost innovation within the team. I firmly believe that technology is strategy's best ally. To dive deeper into my professional journey, I'll be waiting for you on my LinkedIn profile.