You need to compare how users acquired in January behave versus those acquired in February. Or understand if users who performed a specific action churn at different rates. That's cohort analysis — and Amplitude makes it easy to group users, segment your data by those groups, and spot behavior patterns across your entire user base.
Setting Up a Cohort in Amplitude
A cohort is a group of users that share a common trait or were acquired during the same time window. In Amplitude, you build cohorts in the UI and they're instantly available for segmentation.
Step 1: Initialize your tracking
Ensure the Amplitude SDK is initialized in your app. Users need to be tracked with consistent identifiers and events so Amplitude can group them into cohorts.
import * as amplitude from '@amplitude/analytics-browser';
amplitude.init('YOUR_API_KEY', '[email protected]', {
serverUrl: 'https://api2.amplitude.com'
});Step 2: Set user properties that define the cohort
Add properties to users that will define their cohort membership. For example, set signup_month or acquisition_source. These properties become the basis for Property cohorts in Amplitude.
amplitude.setUserProperties({
'signup_month': 'Q1_2024',
'acquisition_source': 'organic',
'plan_tier': 'pro'
});Step 3: Navigate to Cohorts and create a new one
In Amplitude, click Cohorts in the left sidebar. Click Create Cohort and select your cohort type: Property (based on user attributes), Behavioral (users who performed an event), or First Touch (acquired in a date range).
// For behavioral cohorts, track the defining event
amplitude.track('Completed signup', {
'signup_timestamp': new Date().toISOString(),
'company_size': 'enterprise'
});Step 4: Save the cohort
Define your cohort conditions (e.g., users with acquisition_source == 'organic' or users who triggered 'Completed signup' between Jan 1 and Mar 31, 2024). Click Save Cohort. Amplitude processes it in the background — check back in a few minutes.
// Include cohort identifiers with every event for reliable segmentation
amplitude.identify(new amplitude.Identify().set('cohort', 'Q1_2024_organic'));
amplitude.track('Page Viewed', { 'page': 'dashboard' });Analyzing Behavior by Cohort
Once your cohorts are saved, segment any Amplitude chart by cohort to compare user groups side-by-side.
Step 1: Open an event analysis
In Events, select the event you want to analyze (e.g., Subscription Upgrade) and the metric (e.g., Unique Users or Event Totals).
amplitude.track('Subscription Upgrade', {
'previous_plan': 'basic',
'new_plan': 'pro',
'upgrade_value': 29,
'cohort': 'Q1_2024_organic'
});Step 2: Segment by cohort
Click Segment and choose your cohort. Amplitude displays separate lines or bars for each cohort in your chart. Compare metrics across groups — e.g., Q1 users upgrade at 12% while Q2 users upgrade at 8%.
// Ensure cohort data is consistent across sessions
let cohort = sessionStorage.getItem('user_cohort');
if (!cohort) {
cohort = `acquisition_${new Date().toISOString().split('T')[0]}`;
sessionStorage.setItem('user_cohort', cohort);
}
amplitude.setUserProperties({ 'cohort': cohort });Step 3: Interpret the results
Look for patterns across cohorts. Declining cohorts (earlier acquisition cohorts with lower metrics) reveal acquisition quality trends. Flat cohorts show steady behavior. Use this to spot whether recent acquisition channels produce better long-term users.
// Track cohort-specific behavior for deeper analysis
amplitude.track('Feature Adopted', {
'feature': 'custom_dashboards',
'cohort': 'Q1_2024',
'days_to_adoption': 14
});Using Cohorts for Retention Analysis
Cohort analysis shines in retention charts — see how long users from different acquisition windows stay active.
Step 1: Open the Retention chart
Click Retention in the sidebar. Select your retention event (e.g., Page Viewed, Created Report, or any core action users repeat). This is the behavior you're tracking over time.
// Track a consistent retention event
amplitude.track('Page Viewed', {
'page_type': 'dashboard',
'session_id': generateSessionId()
});Step 2: Set cohort definition to time-based
In the retention chart, set Cohort Definition to First Touch or specify a Custom Date Range. Amplitude automatically groups users by the week or month they were first acquired.
// Timestamp user acquisition precisely
amplitude.identify(
new amplitude.Identify()
.set('signup_date', new Date().toISOString())
.set('signup_month', 'March 2024')
.set('source', 'paid_google')
);
amplitude.track('Signed Up', {});Step 3: Analyze retention by cohort
Read the retention table: rows are acquisition cohorts, columns are weeks or months after signup. A cell shows the % of that cohort retained. Declining columns reveal churn; flat rows show strong retention. Early cohorts with declining retention may indicate a product issue fixed later.
// Track churn signals alongside retention
amplitude.track('Engagement Decline', {
'days_since_signup': daysActive,
'events_this_week': eventCount,
'cohort': userCohort,
'churn_risk': churnScore
});Common Pitfalls
- Forgetting to set user properties or timestamps — if users aren't tagged with cohort metadata, they won't group correctly in Amplitude.
- Mixing up First Touch cohorts (time-window) with Property cohorts — First Touch is best for acquisition analysis, Property cohorts are better for behavioral grouping.
- Expecting cohorts to update in real-time — Amplitude recalculates cohorts on a schedule (usually daily), not instantly.
- Overcrowding charts with too many cohorts — more than 4–5 cohorts becomes hard to read; create separate charts or filter to compare specific cohorts.
Wrapping Up
Cohort analysis in Amplitude reveals which user groups have the strongest retention, highest upgrade rates, and longest lifetime value. By grouping users and comparing them over time, you can spot acquisition and product trends that raw event data alone would miss. If you want to track this automatically across tools, Product Analyst can help.