You've got thousands of users. But are they all the same? Cohort analysis in Mixpanel lets you group users by when they signed up, what they did, or who they are—then watch how each group behaves over time. It's the difference between asking 'did retention go up?' and 'did *new users in March* stick around?'
What is a cohort?
A cohort is a group of users who share something in common—a behavior, a signup date, or a trait.
Understand cohort groups
A cohort groups users by a single condition. Users who signed up in March is a cohort. Users who completed onboarding is a cohort. Users from a specific country is a cohort. The key: they all share one characteristic, and you can track that group's behavior over weeks or months.
// Mixpanel tracks all users with a distinct_id
// When you set a user property, they're automatically segmentable
mixpanel.identify(user_id);
mixpanel.register({
'signup_month': 'March 2025',
'country': 'US'
});
mixpanel.track('User Signup', { 'signup_month': 'March 2025' });Why cohorts matter
Without cohorts, metrics blur together. You see 10% churn, but you don't know if it's because of a recent product change, or because your March users always churn faster. Cohorts let you isolate variables and see the truth.
// Set properties that define cohort membership
mixpanel.register({
'signup_cohort': 'Q1_2025',
'company_size': 'enterprise',
'onboarding_complete': true
});
// Now users are segmentable by these properties in the Cohorts sectionCreating and analyzing cohorts in Mixpanel
Mixpanel's Cohorts section lets you build groups visually and track their behavior.
Create a cohort in the UI
Go to Cohorts > Create Cohort. Choose a condition (event or property). For example: Event occurred > select User Signup > in the last 30 days. Name it New Users (Last 30d) and save.
// Create a cohort via Mixpanel API
const createCohort = async () => {
await fetch(
'https://mixpanel.com/api/2.0/cohorts/list',
{
method: 'POST',
headers: {
'Authorization': `Basic ${btoa('YOUR_PROJECT_TOKEN:YOUR_SERVICE_PASSWORD')}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'New Users (Last 30d)',
event: 'User Signup',
event_selectors: [{
name: 'User Signup',
operator: 'in the last',
unit: 'days',
value: 30
}]
})
}
);
};View cohort size and composition
Once saved, click on the cohort to see how many users match the condition. Mixpanel shows the cohort size over time, so you can see if your New Users (Last 30d) cohort grows as you onboard more customers.
// Query cohort membership via Mixpanel API
const getCohortMembers = async (cohort_id) => {
const response = await fetch(
`https://mixpanel.com/api/2.0/cohorts/${cohort_id}/members`,
{
method: 'GET',
headers: {
'Authorization': `Basic ${btoa('YOUR_PROJECT_TOKEN:YOUR_SERVICE_PASSWORD')}`
}
}
);
const data = await response.json();
console.log(`Cohort has ${data.result.length} members`);
};Analyze cohort behavior over time
Use the Retention board to compare cohorts. Select your New Users (Last 30d) cohort > choose a key event like Account Upgrade. You'll see what % of that cohort upgraded over weeks—that's retention by cohort.
// Track events that signal cohort-based retention
mixpanel.track('Account Upgrade', {
'days_since_signup': 15,
'user_cohort': 'New Users (Last 30d)',
'plan_selected': 'pro',
'upgrade_source': 'onboarding_flow'
});
// Segment this event by cohort in Retention reportsPractical cohort analysis patterns
Here are setups product teams use to spot retention trends and feature adoption.
Retention by signup month
Create monthly cohorts: Jan 2025 Signups, Feb 2025 Signups, Mar 2025 Signups. Run Retention with each cohort to see if newer users stick around longer. This shows if your product got stickier or if onboarding improved.
// Set signup_month to enable monthly cohorts
const trackSignup = (signup_date) => {
const month = new Date(signup_date).toLocaleString('en-US', {
month: 'long',
year: 'numeric'
});
mixpanel.identify(user_id);
mixpanel.register({ 'signup_month': month });
mixpanel.track('User Signup', { 'signup_month': month });
};
// Filter by signup_month in Cohorts > Create CohortFeature adoption by cohort
Create a Power Users cohort: users who've triggered Feature X at least 5 times. Then run Retention to see if power users churn less. If they do, your feature drives stickiness.
// Track feature usage for adoption cohorts
mixpanel.track('Dashboard Created', {
'feature': 'analytics_dashboard',
'workflow': 'create_first_dashboard',
'time_spent_seconds': 240
});
// In Cohorts: Event occurred > "Dashboard Created" > count >= 5
// Result: 'Power Users (Dashboard)' cohortCommon Pitfalls
- Defining cohorts on properties that change daily—use signup date or fixed time ranges instead of volatile traits
- Not including cohort identifiers in your events—you can't analyze by cohort if events don't reference which cohort the user belongs to
- Comparing cohorts of wildly different sizes without normalizing—always look at percentages (% retained) not raw counts
- Forgetting to set a
distinct_idbefore tracking—users without IDs won't be grouped into cohorts
Wrapping Up
Cohort analysis turns 'X% of users did Y' into 'X% of *March signups* did Y'—it's the lens that reveals truth in your user metrics. Once you've built a few cohorts, you'll spot patterns in retention, feature adoption, and churn that dashboards alone can't show. If you want to build and track cohorts automatically across all your tools, Product Analyst can help.