5 min read

How to Set Up Cohort Analysis in Amplitude

Cohorts let you group users by behavior or attributes and track them over time. In Amplitude, cohorts are the foundation for comparing how different user segments engage with your product.

Create Your First Cohort

Cohorts in Amplitude are groups of users that match specific conditions. You define these conditions in the Amplitude UI, and they update automatically as your data comes in.

Navigate to the Cohorts section

Open Amplitude and go to Cohorts in the left sidebar. Click Create Cohort to start defining a new user group.

Define cohort membership criteria

Set up the conditions that determine who belongs to the cohort. You can filter by user properties (like subscription tier or signup date), events (like 'Subscribed'), or behavioral patterns (like 'active in the last 7 days'). Save your cohort when the conditions are set.

javascript
import * as amplitude from '@amplitude/analytics-browser';

// Initialize the SDK
amplitude.init('YOUR_API_KEY');

// Set user properties that cohorts will filter on
amplitude.setUserProperties({
  subscription_tier: 'premium',
  signup_date: Math.floor(Date.now() / 1000),
  company_size: 100
});

// Track the event that defines the cohort
amplitude.track('Subscription Started', {
  plan: 'annual',
  price: 99.99
});
Setting properties and tracking events that define cohort membership
Tip: Use descriptive cohort names like 'Annual Subscribers' or 'Churned Last Month' — vague names like 'Cohort_1' are harder to reference later.

Apply Cohorts to Your Analysis

Once your cohorts are defined, segment your metrics by cohort to compare behavior across different user groups.

Create a chart and segment by cohort

In Insights, create a new chart and build your metric (like 'Daily Active Users' or 'Total Revenue'). Under Segment, select your cohort. This breaks down the metric by cohort membership, showing you how each group behaves.

javascript
import * as amplitude from '@amplitude/analytics-browser';

amplitude.init('YOUR_API_KEY');

// Identify a user with properties for cohort matching
const identify = new amplitude.Identify();
identify.set('customer_type', 'enterprise');
identify.set('onboarding_completed', true);
identify.set('last_active_date', Date.now());

amplitude.identify(identify);
Using Identify to set properties that determine cohort membership

Compare and export cohort data

Once segmented, you'll see metrics broken down by cohort. Compare retention rates, feature adoption, or revenue across cohorts. Click Export to download the data for further analysis or dashboard integration.

Watch out: Cohorts update on a daily schedule, not in real-time. New users matching a cohort condition might take up to 24 hours to populate.

Export Cohorts to Other Tools

Amplitude cohorts can be synced to external platforms so you can act on cohort membership in your marketing tools or product.

Fetch cohort data via the Amplitude API

Use the Amplitude Cohort API to programmatically fetch users in a cohort. This is useful for syncing to email platforms, feature flags, or triggering in-app messaging based on cohort membership.

javascript
// Fetch cohort members using the Amplitude REST API
const apiKey = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';
const cohortId = 'YOUR_COHORT_ID';

const auth = btoa(`${apiKey}:${secretKey}`);

fetch('https://amplitude.com/api/2/cohort/members', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${auth}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    cohort_id: cohortId
  })
})
.then(response => response.json())
.then(data => {
  console.log('Cohort members:', data.members);
  // Use this data to sync to other tools
});
Fetching cohort membership via the Amplitude REST API

Common Pitfalls

  • Creating cohorts that are too broad — a 'all users' cohort won't be useful. Add meaningful filters like 'signed up in last 90 days' or 'used feature X'.
  • Forgetting to track the properties you're filtering on — if your cohort is based on 'subscription_tier', ensure your app is setting that property on every user via setUserProperties().
  • Confusing user properties with event properties — cohorts filter on persistent user properties (like subscription_tier) or event data, not one-off event properties.
  • Not revisiting cohort definitions when your product evolves — if 'premium' users gain a new feature, your existing cohort definition might no longer match your business intent.

Wrapping Up

Cohorts are your first step toward understanding user behavior patterns in Amplitude. Start with one simple cohort (like 'active last week'), segment a key metric by it, and build from there. If you want to track this automatically across tools, Product Analyst can help.

Track these metrics automatically

Product Analyst connects to your stack and surfaces the insights that matter.

Try Product Analyst — Free