6 min read

How to Track Retention Analysis in Mixpanel

User retention is where you find out if your product actually keeps people coming back. Mixpanel's Retention analysis shows you exactly which cohorts return—and which ones don't. But first, you need to be tracking the right events with the right properties.

Track Events That Matter for Retention

Retention analysis starts with events. You need to track when users sign up (your cohort event) and when they come back (your returning event).

Install the SDK and initialize tracking

Add the Mixpanel JavaScript SDK to your app. Initialize it with your project token, which you can find in Project Settings > Token. Set persistence to localStorage so user identity survives page reloads.

javascript
import mixpanel from 'mixpanel-browser';

mixpanel.init('YOUR_PROJECT_TOKEN', {
  track_pageview: false,
  persistence: 'localStorage'
});
Initialize Mixpanel with your project token from settings

Track the initiating event (signup or activation)

This event defines your cohort. Usually it's signup or first_login. Include properties that help you segment retention later: plan type, signup source, user segment, or onboarding status. Be consistent with property names.

javascript
mixpanel.track('signup', {
  'plan_type': 'premium',
  'signup_source': 'organic_search',
  'user_segment': 'enterprise',
  'onboarding_completed': false
});
Track signup with properties you'll filter by later

Track return events consistently

These are the actions you want to see users repeat. Common choices: login, dashboard_opened, feature_used, or query_executed. Pick the event that represents active, intentional use—not passive events like page_view that inflate numbers.

javascript
// Track intentional return events
mixpanel.track('dashboard_opened', {
  'feature': 'real_time_analytics',
  'session_id': sessionId
});

mixpanel.track('query_executed', {
  'feature': 'custom_events',
  'query_type': 'funnel'
});
Track specific actions, not passive pageviews
Watch out: If you track user_id on signup but use a different identifier format on return events, Mixpanel won't stitch users correctly. Use mixpanel.identify() to set a consistent distinct_id across all events.

Build Your Retention Cohort in Mixpanel

Once events flow in, you'll configure the retention analysis to see cohort behavior over time.

Navigate to Retention and pick your initiating event

Go to Analytics > Retention. Select the event that groups users into cohorts—usually signup or first_login. Mixpanel will create cohorts based on when each user first triggered this event.

javascript
// Ensure your initiating event is tracked on user signup:
mixpanel.track('signup', {
  'user_id': userId,
  'timestamp': new Date().toISOString(),
  'plan_type': planType,
  'company': companyName
});
Example initiating event with properties for segmentation

Select your returning event and interval

Choose the event that indicates a return (e.g., dashboard_opened, login). Pick your interval: Day for daily active apps, Week for most SaaS, or Month for enterprise products. Week is usually the sweet spot—Day is noisy, Month takes too long to collect data.

javascript
// Track return events consistently throughout the day:
mixpanel.track('login', {
  'user_id': userId,
  'login_source': 'direct',
  'device_type': 'web'
});

mixpanel.track('dashboard_opened', {
  'user_id': userId
});
Return events tracked multiple times per session add depth to retention

Add filters to segment your cohorts

Click Add filter to break retention down by plan, source, segment, or any property you tracked. This reveals which user groups stick around: premium vs. free, organic vs. paid, enterprise vs. startup.

javascript
// Properties you track become filterable dimensions:
mixpanel.track('signup', {
  'user_id': userId,
  'plan_type': 'premium',    // Filter by this
  'region': 'US',            // Or by region
  'industry': 'SaaS',        // Or industry
  'has_cc_on_file': true     // Or payment status
});
Plan ahead: track properties you'll want to segment by
Tip: If your retention table is mostly empty or shows 100% across the board, check that your return event is actually firing. Use Live View in Project Settings to verify events are flowing in real-time.

Interpret Results and Spot Patterns

Your retention table now shows cohort behavior. Day 0 is always 100% (everyone counts on signup). Day 1 shows the % who came back. Day 7 shows week-1 retention—a key metric for product-market fit.

Read the retention curve

A healthy retention curve drops quickly from Day 0 to Day 3 (users try and bounce), then flattens out. If it drops from 100% to 5% by Day 7, something is broken. If it holds at 40% week 1, you have a product users care about. Benchmarks: consumer apps 20-40%, SaaS 60%+.

javascript
// Log cohort metrics to track trends:
console.log(`Day 0: ${dayZeroCount} users signed up`);
console.log(`Day 1: ${((day1Count / dayZeroCount) * 100).toFixed(2)}% returned`);
console.log(`Day 7: ${((day7Count / dayZeroCount) * 100).toFixed(2)}% came back`);
console.log(`Day 30: ${((day30Count / dayZeroCount) * 100).toFixed(2)}% stayed`);
Calculate retention percentages to track improvement over time

Segment to find engaged cohorts

Filter by plan_type, signup_source, or onboarding_completed. You might find premium users retain at 70% but free users at 10%. That's actionable: focus on premium conversion. Or you might find that users who complete onboarding stick around—justify that investment.

javascript
// Track properties that let you identify high-retention segments:
mixpanel.track('signup', {
  'user_id': userId,
  'plan_type': userPlan,                    // Compare retention
  'onboarding_completed': hasFinished,      // Correlation signal
  'feature_flag_experiment': experimentId,  // A/B test impact
  'team_size_category': category            // Product-market fit signal
});
Segment properties help identify which changes drive better retention

Watch for cliff drops and investigate

If retention drops from 50% on Day 1 to 15% by Day 3, users are leaving after first session. Something in onboarding is broken. If retention holds steady, you're stable. Use Export to CSV to trend retention week-over-week and catch regressions early.

javascript
// Track events that correlate with drop-off:
mixpanel.track('onboarding_abandoned', {
  'user_id': userId,
  'step_reached': 'dashboard_setup',
  'reason': 'too_complex',
  'time_spent_seconds': 180
});

mixpanel.track('feature_abandoned', {
  'user_id': userId,
  'feature': 'custom_queries',
  'reason': 'documentation_unclear'
});
Track drop-off events to correlate them with retention cliff drops
Watch out: Retention numbers lie if you're tracking passive events like page_view. Bots and idle users inflate numbers. If 95% of users are 'retained' by that metric, you're measuring infrastructure, not engagement. Use intentional actions like feature_used or query_executed instead.

Common Pitfalls

  • Tracking inconsistent property names or identifiers between signup and return events—if you use user_id on signup but customer_id on login, Mixpanel treats them as different users and retention tanks
  • Measuring retention on passive events like page_view instead of intentional actions—you'll see false-positive retention from bots and users who abandon your product
  • Picking the wrong interval—Day-level retention is too noisy for SaaS (dominated by daily active users); Month-level takes months to collect meaningful data. Use Week for most products
  • Not setting user identity with mixpanel.identify() before tracking—events won't stitch to the same user across sessions, devices, or logins, breaking retention cohorts

Wrapping Up

You're now tracking retention properly and can see exactly which cohorts stick around, which drop off, and why. You'll spot which user segments, plans, or onboarding paths drive retention. 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