6 min read

How to Set Up Cohort Analysis in Mixpanel

Cohorts let you group users by behavior or properties and track how they evolve over time. In Mixpanel, a cohort might be 'users who signed up in January and completed onboarding' — then you can analyze their retention, monetization, or feature adoption separately from the rest of your user base. Setting up cohorts properly saves hours of manual filtering in reports.

Step 1: Track the Events and Properties You'll Need

Before you can build a cohort, Mixpanel needs the right data. Start by instrumenting the events and user properties that will define your cohort.

Set up event tracking for cohort criteria

Track meaningful events that distinguish user groups. If you want a cohort of 'users who completed onboarding,' you need an event fired when someone finishes that step. Add mixpanel.track() calls to your app at key moments.

javascript
// Track when a user completes onboarding
mixpanel.track('Onboarding Completed', {
  'timestamp': new Date(),
  'cohort_source': 'app_signup'
});

// Track feature adoption
mixpanel.track('Feature Used', {
  'feature_name': 'Advanced Reports',
  'plan_type': 'Pro'
});
Events tracked with clear names and properties for later segmentation in cohorts.

Set user properties for demographic or behavioral attributes

Use mixpanel.people.set() to store persistent user attributes like signup date, company size, plan type, or any property you want to segment by. These properties stay with the user and update as they change.

javascript
// Set user properties after signup or profile update
mixpanel.people.set({
  '$email': user.email,
  '$name': user.name,
  'signup_date': new Date().toISOString(),
  'company_size': 'mid-market',
  'customer_segment': 'SaaS'
});
Reserved properties start with $ (like $email); custom properties don't use the prefix.
Watch out: Mixpanel's reserved properties (like $email, $name) start with $. Custom properties like signup_date or company_size should not. Event names work best in past tense ('Feature Adopted' not 'Feature Adoption') for clarity in reports.

Step 2: Create a Cohort in the Mixpanel UI

Once event and property data is flowing, build your cohort by defining who belongs in it.

Navigate to the Cohorts section

In your Mixpanel project, click Cohorts in the left navigation. This is where you'll see all saved cohorts and create new ones.

Click 'Create Cohort' and name it clearly

Give your cohort a name that describes the group, like 'January 2026 Signups' or 'Pro Plan Users — Advanced Reports'. A descriptive name makes it easy to find and reuse across reports.

Define cohort criteria using filters

Set up filters to define membership. You can filter by Event (e.g., 'Completed Onboarding'), User Property (e.g., 'plan_type = Pro'), or Date Range (e.g., 'signed up between Jan 1–31'). Mixpanel combines filters with AND/OR logic — choose carefully to capture the right users.

javascript
// In the UI, this translates to filter logic like:
// Event: 'Onboarding Completed' 
// AND User Property: 'signup_date' is between '2026-01-01' and '2026-01-31'
// AND User Property: 'company_size' equals 'mid-market'

// To programmatically query cohort members via Mixpanel API:
const cohortId = 'your_cohort_id';
const exportUrl = `https://data.mixpanel.com/api/2.0/cohort/members?cohort_id=${cohortId}`;
// Requires Mixpanel API token in Authorization header
UI filters define cohort membership; the API example shows how to fetch cohort data server-side.

Save the cohort

Click Save Cohort. Mixpanel processes the data and populates the cohort with matching users. The first run may take a few moments depending on your data volume.

Tip: Use date ranges wisely. Cohorts like 'Signups in Q1' are stable for tracking retention. For dynamic cohorts that update daily, enable Recurring Cohort in the settings — Mixpanel will refresh it automatically.

Step 3: Use Your Cohort in Analysis

Now that your cohort is saved, apply it to your reports to compare behavior across groups.

Open Insights, Funnels, or Retention and filter by your cohort

In any report, click Add Filter and select your saved cohort. Mixpanel analyzes that cohort's behavior separately. You can compare multiple cohorts by adding them as separate segments in the same report.

javascript
// Example: Using Mixpanel API to export retention data filtered by cohort
const retentionQuery = {
  "from_date": "2026-01-01",
  "to_date": "2026-03-31",
  "unit": "day",
  "retention_type": "retention",
  "event": "Feature Used",
  "born_event": "Onboarding Completed",
  "born_where": "in_cohort(\"January 2026 Signups\")"
};
// Submit via Mixpanel's Data Export API with your project token
API structure for querying retention filtered by a named cohort.

Compare retention or conversion rates across cohorts

Run a Retention report and segment by your cohort. For example, compare 'January Signups' vs 'February Signups' to see if user quality changed month-over-month. Or run a funnel and compare conversion rates across cohorts to spot drop-off differences.

Watch out: Cohort data is retroactive only to the cohort creation date. You can't analyze 'January Signups' retroactively if you create that cohort in March — Mixpanel only counts users matching the criteria at creation time. Plan cohorts early if historical analysis matters.

Common Pitfalls

  • Forgetting to track events or set properties before creating the cohort — your cohort will be empty if the data doesn't exist in Mixpanel yet.
  • Using overly broad criteria like 'Any Event' (includes bot traffic) or overly narrow criteria (too few users to see patterns) — test your filters with a preview first.
  • Assuming cohorts update in real-time — Mixpanel updates cohorts on a schedule, and large cohorts may have a slight delay.
  • Naming cohorts generically like 'Cohort_1' instead of descriptively — 'High-Value Customers: Revenue > $1000/mo' is useless vs 'Cohort_1'.

Wrapping Up

You now have a saved cohort in Mixpanel that you can reuse across retention, funnel, and insight reports. Cohorts are powerful for isolating user segments and understanding how different groups behave — whether it's by signup date, feature adoption, or customer tier. If you want to automate cohort analysis and surface insights 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