Churn is where you lose users — and PostHog makes it visible. You can measure how many users stop engaging, when they disappear, and which cohorts are most at risk. This post shows you how to set up churn tracking in PostHog so you can act before users leave.
Set Up Event Tracking and User Identification
Before you can measure churn, PostHog needs to know who your users are and what they're doing.
Identify Your Users
Call posthog.identify() when a user signs up or logs in. This ties events to a real user ID so PostHog can track them over time.
posthog.identify(
'user_123',
{
email: '[email protected]',
name: 'Jane Doe',
plan: 'pro'
}
);Capture Engagement Events
Log events for key user actions: login, feature usage, payment, support ticket. These events define what 'active' means for your product. Pick 1–2 events that represent core engagement.
// Track a user login
posthog.capture('user_login');
// Track a feature usage event
posthog.capture('dashboard_viewed', {
dashboard_type: 'sales',
load_time_ms: 245
});
// Track a subscription event
posthog.capture('plan_upgraded', {
plan_name: 'enterprise',
monthly_price: 1200
});Choose Your Retention Event
Decide which event defines an 'active' user. For SaaS, this is often login or a feature-specific action like dashboard_viewed. Don't pick too broad an event like page_view or too narrow like payment — aim for genuine engagement.
Measure Churn with PostHog's Retention Insight
Open the Retention Insight
In PostHog, go to Insights > Retention. This tool shows what percent of users who did an event on Day 1 come back and do it again in subsequent days, weeks, or months.
// Query retention data via PostHog REST API
const response = await fetch(
'https://your-posthog-instance.com/api/insight/retention/',
{
method: 'GET',
headers: {
'Authorization': `Bearer ${POSTHOG_API_KEY}`,
'Content-Type': 'application/json'
}
}
);
const retentionData = await response.json();
console.log(retentionData.result);Configure Your Retention Settings
Set your Returning Event (the action that defines 'active'), Returning Interval (daily, weekly, or monthly), and Date Range. For monthly churn, use weeks or months. For daily churn, use days.
// Example: Measure weekly churn for 'dashboard_viewed'
const retentionConfig = {
retention_type: 'retention',
retention_reference: 'total',
returning_event: 'dashboard_viewed',
period: 'Week', // Day, Week, Month
date_from: '-12w', // Last 12 weeks
date_to: 'today'
};
// In PostHog UI: Insights > Retention
// Returning Event: dashboard_viewed
// Returning Interval: Week
// Days/Weeks shown: 12Read the Cohort Table
PostHog displays a table showing cohorts by start date and their return rates. A 30% Week 4 retention means 70% churn. Hover over cells to see exact counts or export data for deeper analysis.
Segment Churn by User Properties
Filter Retention by Cohorts
In Insights > Retention, add a Filter to see churn rates for specific groups: high-value customers, free users, or users from a certain region. Click Add Filter and select a user property.
// Example: Measure churn for 'pro' plan users only
const filteredRetention = {
retention_type: 'retention',
returning_event: 'dashboard_viewed',
period: 'Week',
filters: [
{
key: 'plan',
value: 'pro',
operator: 'exact'
}
]
};
// In PostHog UI:
// Add Filter > plan = pro
// This shows churn rates only for pro plan usersCreate a Churn Cohort for Re-engagement
Go to Data > Cohorts and create a new cohort like 'Users who haven't logged in this week' or 'Free plan users with low activity.' Use this cohort to target emails, in-app messages, or win-back campaigns.
// Track re-engagement campaigns targeting your churn cohort
posthog.identify('user_456', {
churn_risk: true,
days_since_login: 14,
plan: 'free'
});
posthog.capture('re_engagement_email_sent', {
cohort: 'inactive_free_plan',
email_template: 'win_back_offer',
incentive: '20% discount'
});
// Later, track if they re-engage
posthog.capture('user_login_after_churn_email', {
cohort: 'inactive_free_plan',
days_to_return: 3
});Common Pitfalls
- Picking the wrong retention event — 'page_view' is too noisy, 'payment' is too sparse. Use an event that represents core engagement with your product.
- Ignoring early cohort bias — Week 1 retention for brand-new users looks artificially high because they're still onboarding. Compare same-age cohorts or look at Week 4+.
- Churn cohorts go stale — a 'Users who haven't logged in' cohort updates once per day. Use it for messaging, but re-check membership before campaigns.
- Over-segmenting retention — drilling into 5+ filters creates small, noisy samples. Start broad (all users), then zoom in on one dimension (plan tier or region).
Wrapping Up
You now have a churn tracking setup in PostHog: events flowing in, retention insights showing cohort drop-off rates, and segmented views of at-risk groups. Use this data to find patterns — are certain plans churning faster? Does a feature launch change retention? If you want to track this automatically across tools, Product Analyst can help.