Cohorts let you group users by shared behaviors or properties—plan type, signup date, company size—then analyze how each segment converts, churns, or engages. Without cohorts, you're watching aggregate metrics that hide what's really going on beneath the surface. PostHog makes building and using cohorts straightforward.
Set Up User Properties and Identification
Before you can create cohorts, you need to track the properties that define your segments. PostHog's identify() method attaches properties to users.
Identify Users with Segment Properties
Call posthog.identify() when users sign up or update their profile. Pass a user ID and properties that describe the segment they belong to—like plan, company_size, or signup_date. PostHog stores these on the user's profile and uses them to build cohorts.
posthog.identify(
'user-123',
{
email: '[email protected]',
plan: 'pro',
company_size: '50-100',
signup_date: '2025-01-15',
is_paying_customer: true
}
);Include Properties in Event Captures
When you log events with posthog.capture(), include properties that signal segment membership. If a user signs up on the free plan, capture plan: 'free' with the event. PostHog uses event properties to build cohorts based on user behavior patterns.
posthog.capture('user_signed_up', {
plan: 'free',
referrer: 'organic',
invited_by_team: false
});
posthog.capture('payment_processed', {
plan_type: 'annual',
amount_cents: 99900,
currency: 'USD'
});plan_type in one place and planType in another, PostHog treats them as different properties.Create and Configure Cohorts
Navigate to Data Management > Cohorts in PostHog and define groups based on the properties and events you're tracking.
Build a Property-Based Cohort
Click New cohort and select Based on properties. Choose a property (e.g., plan) and set the condition (e.g., plan equals pro). PostHog immediately segments all users matching that condition into the cohort. You can combine multiple properties with AND/OR logic.
// Create a cohort via PostHog API
fetch('https://YOUR_POSTHOG_URL/api/projects/YOUR_PROJECT_ID/cohorts/', {
method: 'POST',
headers: {
'Authorization': `Bearer ${POSTHOG_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Pro Plan Users',
description: 'Users on the pro or pro-plus plan',
filters: {
properties: [
{
key: 'plan',
value: ['pro', 'pro_plus'],
operator: 'is_any'
}
]
}
})
});Build a Behavior-Based Cohort
Select Based on events to define a cohort from user actions. For example, cohort all users who completed onboarding in the last 30 days. Set the event name, time window, and conditions, and PostHog matches everyone who performed that action.
// Create an event-based cohort via API
fetch('https://YOUR_POSTHOG_URL/api/projects/YOUR_PROJECT_ID/cohorts/', {
method: 'POST',
headers: {
'Authorization': `Bearer ${POSTHOG_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Recently Onboarded Users',
description: 'Completed onboarding in the last 30 days',
filters: {
events: [
{
id: 'onboarding_completed',
type: 'events',
time_value: 30,
time_interval: 'day',
value: 'true'
}
]
}
})
});Name and Review Your Cohort
Give your cohort a descriptive name (e.g., High-Value Users, Active Last 7 Days). PostHog updates membership in real time as users match the criteria. Review the cohort size to make sure it's meaningful—a cohort with 2 users won't yield useful analysis.
plan: 'pro' AND monthly_spend > 5000 AND last_active_date: last_30_days. Use AND/OR operators to build rich segments.Use Cohorts in Analysis
Once your cohorts are built, filter insights and funnels by them to compare how segments behave.
Filter Insights by Cohort
Create an insight (like daily active users or feature adoption). Click Filter and select your cohort. PostHog shows the metric only for that cohort's users. Add multiple filters for different cohorts to compare side-by-side.
// Query insights filtered by cohort (via API)
fetch('https://YOUR_POSTHOG_URL/api/projects/YOUR_PROJECT_ID/insights/', {
method: 'POST',
headers: {
'Authorization': `Bearer ${POSTHOG_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Pro vs Free Signups',
insight: 'TRENDS',
events: [{ id: 'user_signed_up' }],
properties: [
{
key: 'plan',
value: ['pro', 'free'],
operator: 'is_any'
}
],
breakdown_type: 'event',
breakdown: 'plan'
})
});Segment Funnels by Cohort
Open a Funnel and add a cohort as a breakdown. PostHog shows dropout rates separately for each cohort, revealing which segments struggle with key flows. This is where cohorts shine—you spot that free users drop 60% at checkout while pro users drop 10%.
Common Pitfalls
- Inconsistent property names across events—if you log
plan_typein one event andplanin another, PostHog treats them as separate properties, and your cohorts won't capture both. - Creating overly broad cohorts—a cohort of 'all users' or 'anyone who visited' provides no insight. Build cohorts around specific attributes or behaviors that actually segment your audience.
- Inconsistent user IDs—if you identify users as
user-123sometimes and[email protected]other times, PostHog treats them as different people and cohort membership breaks. - Ignoring cohort size—a cohort with only a few users won't tell you anything meaningful. Check your cohort size before relying on comparisons.
Wrapping Up
You now have cohorts that segment users by properties and behavior, letting you compare how different groups convert, churn, and engage. Cohorts expose patterns hidden in aggregate metrics—like discovering that your pro tier has 3x higher activation than free users, or that one referral source converts at double the rate of others. If you want to track this automatically across tools, Product Analyst can help.