Retention is the metric that actually matters—if users aren't coming back, nothing else matters. PostHog's Retention view lets you see exactly how many users return after their first action, broken down by cohorts and time periods. This is how you spot whether a feature is sticky.
Creating Your First Retention Insight
The Retention view is PostHog's dedicated tool for cohort analysis. You specify a starting event, a returning event, and the time interval you want to measure.
Navigate to the Retention View
In PostHog, go to Insights in the left sidebar, then select Retention from the menu. This opens the retention cohort builder where you define your starting and returning events.
// PostHog retention data via the API
const retention = await fetch('https://your-posthog.instance.com/api/projects/{project_id}/insights/', {
method: 'POST',
headers: { 'Authorization': `Bearer ${apiKey}` },
body: JSON.stringify({
insight: 'retention',
events: [
{
id: 'sign_up',
type: 'events',
order: 0
}
],
retention_type: 'retention_first_time'
})
});Define Your Starting Event
Set the event that defines your cohort—usually sign_up, first_purchase, or activate_account. Every user who performed this event on a given date becomes part of that cohort. This is your Day 0.
// Track the starting event that defines your cohort
posthog.capture('sign_up', {
signup_source: 'organic',
plan_tier: 'free',
company_industry: 'saas'
});Set the Returning Event
Choose what counts as a return. For SaaS, this is often $pageview, login, or feature_usage. PostHog calculates what percentage of each cohort came back on Day 1, Day 7, Day 30, etc. Broader events (like any interaction) catch more returners.
// Later, track the returning event
posthog.capture('$pageview', {
$current_url: 'https://app.example.com/dashboard'
});
posthog.capture('user_action', {
action_type: 'created_report'
});Choose Your Time Granularity
PostHog defaults to Day buckets. For longer-term retention, switch to Week or Month. Daily retention is noisy; weekly and monthly show cleaner trends. Most SaaS companies use Week or Month for Day 7+.
// Configure retention at the insight level
const retentionConfig = {
insight: 'retention',
events: [
{ id: 'sign_up', type: 'events', order: 0 },
{ id: '$pageview', type: 'events', order: 1 }
],
period: 'Week', // 'Day', 'Week', or 'Month'
target_entity: 'user_id'
};$pageview) as your returning event to get a baseline. Then narrow it down to specific actions (like feature usage) to see which features drive stickiness.Filtering and Analyzing Retention Cohorts
Raw retention numbers are useful, but the real insight comes from slicing the data. Filter by user properties, traffic source, or plan tier to see which segments stick.
Add Property Filters to Your Cohort
Click Add filter in the Retention view and filter by properties like signup_source = organic or plan = paid. This isolates retention for specific segments. Organic users might have higher retention than paid acquisition.
// Capture properties that enable filtering later
posthog.capture('sign_up', {
signup_source: 'organic', // or 'paid_search', 'referral'
plan_tier: 'free', // or 'pro', 'enterprise'
utm_source: 'google',
country: 'US'
});Compare Retention Across Segments
Create multiple retention insights to compare side-by-side—one for organic users, one for paid, one for free vs. paid plans. PostHog shows each as a table (Day 0, Day 1, Day 7, etc.) with retention percentages.
// Use feature flags to test retention across variants
const onboardingVariant = posthog.getFeatureFlag('new_onboarding_v2');
posthog.capture('onboarding_complete', {
variant: onboardingVariant ? 'new_v2' : 'control',
time_to_complete: 'under_5_min'
});Export and Share Retention Results
Click the ⋯ menu in your retention insight, then Export to download as CSV. You can also Share to generate a public link for stakeholders—they'll see the cohort table without needing PostHog access.
// Fetch retention data programmatically for custom reports
const getRetentionData = async (projectId, apiKey) => {
const response = await fetch(
`https://your-posthog.instance.com/api/projects/${projectId}/insights/?insight=retention&limit=100`,
{ headers: { 'Authorization': `Bearer ${apiKey}` } }
);
const data = await response.json();
return data.results;
};Common Pitfalls
- Comparing Day 0 (same day as signup) retention with Day 30—cohort sizes drop naturally. Focus on percentages and trends, not raw counts.
- Not excluding internal team members or test accounts. Create a filter to exclude your own domain or use a property like
is_internal = false. - Setting your returning event too narrow (like a single button click). Use broader events like
$pageviewor$identifyto capture true engagement. - Measuring retention on weekly or monthly products without enough historical data. PostHog needs at least 4 weeks of data for weekly retention to stabilize.
Wrapping Up
You now have retention cohorts broken down by segment and time period—the foundation for spotting which user groups and features drive stickiness. PostHog makes it easy to slice and export results for stakeholder reviews. If you want to track retention automatically across PostHog, Amplitude, Mixpanel, and other tools from a single dashboard, Product Analyst can help.