Churn isn't obvious until it hits your bottom line. Mixpanel's retention tools let you define what churn means for your product, then alert you when it crosses a threshold. By the time you're manually checking dashboards, you've already lost customers.
Define Your Churn Signal
Churn is the absence of activity. First, decide what 'activity' means in your product.
Pick your core activity event
Churn is when users stop doing something that matters. For a SaaS app, that's usually login. For a marketplace, it's a purchase or listing creation. For a mobile app, it could be any screen_view. Be specific—don't use 'pageview' if 'active_session' is what actually signals engagement.
// Track the activity that defines an 'active' user
mixpanel.track('User Login', {
'product_plan': 'pro',
'days_since_signup': 45,
'region': 'US'
});
// Or for a marketplace
mixpanel.track('Listing Created', {
'seller_tier': 'premium',
'category': 'electronics'
});Set your inactivity window
In Mixpanel, go to Insights and create a Retention chart. Set it to show which users return after being inactive. Choose your window: 7 days (highly engaged products), 30 days (most SaaS), or 60+ days (low-frequency apps like tax software).
// Calculate churn rate using Mixpanel retention data
// Churn = (users_inactive_past_30_days) / (total_active_users)
const cohortStartDate = '2026-02-24'; // 30 days ago
const cohortEndDate = '2026-03-26'; // today
const inactivityWindow = 30; // days
// In Mixpanel Insights, the Retention view shows this automatically
// Filter for: users where last_event_date < today - 30 days
console.log('Set retention lookback window to 30 days in Insights UI');Create a Cohort for Churned Users
Instead of manually checking dashboards, let Mixpanel automatically segment your churned users.
Build a cohort with inactivity logic
In Mixpanel, go to Cohorts > Create New Cohort. Create a condition: 'User last performed [your core event] more than 30 days ago'. Save it with a descriptive name like 'At Risk: 30 Day Churned'.
// Create a churned cohort via Mixpanel API
// POST to https://mixpanel.com/api/2.0/cohorts
const cohortPayload = {
'cohort_name': 'At Risk: 30 Day Churned',
'description': 'Users with no login event in last 30 days',
'definition': {
'operator': 'and',
'conditions': [{
'filter': 'properties["last_login"]',
'operator': 'not_in_time_range',
'value': { 'days': 30 }
}]
}
};
fetch('https://mixpanel.com/api/2.0/cohorts', {
method: 'POST',
headers: { 'Authorization': `Bearer ${token}` },
body: JSON.stringify(cohortPayload)
}).then(res => res.json()).then(data => console.log('Cohort ID:', data.cohort_id));Monitor cohort size over time
Once the cohort is created, add it to a chart. Go to Insights > Cohort Analysis and select your 'At Risk' cohort. Watch the trend line. A sudden spike means churn is accelerating.
// Query cohort size over a date range
const cohortId = 'abc123xyz'; // from cohort creation response
const startDate = '2026-02-24';
const endDate = '2026-03-26';
fetch(`https://mixpanel.com/api/2.0/cohort/size_history?cohort_id=${cohortId}&from_date=${startDate}&to_date=${endDate}`, {
headers: { 'Authorization': `Bearer ${token}` }
}).then(res => res.json()).then(data => {
data.forEach(point => {
console.log(`${point.date}: ${point.size} churned users`);
});
});Set Up Alerts on Churn Rate Thresholds
Now that you have a cohort tracking churn, configure alerts to notify you when churn spikes.
Create an Insights chart for your churn metric
In Insights > Events, create a chart that counts your churned cohort over time (daily or weekly). You can also create a formula to show churn as a percentage: (churned_users / active_users) × 100.
// Query churn rate using the events API
const churnQuery = {
'event': 'User Login',
'unit': 'day',
'from_date': '2026-02-26',
'to_date': '2026-03-26',
'filters': [{
'property': 'cohort_id',
'operator': 'eq',
'value': 'at_risk_30_day'
}]
};
fetch('https://mixpanel.com/api/2.0/events', {
method: 'POST',
headers: { 'Authorization': `Bearer ${token}` },
body: JSON.stringify(churnQuery)
}).then(res => res.json()).then(data => {
console.log('Daily churn counts:', data);
});Enable alert notifications on the chart
Click the bell icon on your Insights chart. Set a threshold: for example, 'Alert if cohort size exceeds 500 users' or 'Alert if daily churn rate is above 5%'. Choose your notification channels: email, Slack, or webhook.
// Set up an alert rule via API
const alertPayload = {
'chart_id': 'chart_abc123',
'trigger_condition': 'exceeds',
'threshold_value': 500, // units: users in cohort
'check_frequency': 'daily',
'notification_channels': ['email', 'webhook'],
'webhook_url': 'https://your-api.com/webhooks/mixpanel-churn',
'recipient_emails': ['[email protected]']
};
fetch('https://mixpanel.com/api/2.0/alerts', {
method: 'POST',
headers: { 'Authorization': `Bearer ${token}` },
body: JSON.stringify(alertPayload)
}).then(res => res.json()).then(data => console.log('Alert created:', data.alert_id));Test the alert workflow
Don't wait for churn to spike naturally. Manually test your alert by temporarily lowering the threshold or simulating the metric condition. Confirm the notification reaches your email, Slack, and webhook handler.
Common Pitfalls
- Confusing 'churn' with 'inactivity'. A user inactive for 30 days isn't churned until they truly abandon your product. Many users take breaks. Define churn as actual cancellation (account deleted, subscription cancelled) if you have that data.
- Setting your inactivity window too short. 7-day windows create noise from users who are just busy. 30–60 days is more realistic for most SaaS. Use 7 days only if you're a social platform where daily engagement is the norm.
- Alerting on absolute numbers instead of rates. 'Alert when 100 users churn' is useless if you have 10,000 or 1 million users. Always alert on rates or percentage changes relative to your user base.
- Forgetting to test your alert before it matters. Set up the alert, then manually trigger the condition. Verify email, Slack, and webhook all fire. Many teams configure alerts and never confirm they work until something critical happens.
Wrapping Up
You now have a system that automatically segments churned users and alerts you when churn spikes. This moves you from reactive check-ins to proactive early warnings so you can intervene before customers leave. If you want to unify churn monitoring across multiple analytics tools and identify what causes churn, Product Analyst can help.