5 min read

How to Track Cohort Analysis in PostHog

You need to understand how different user groups behave, not just aggregate numbers. PostHog's cohorts let you segment users based on events and properties, so you can compare how new users differ from power users or how customers in different regions engage.

Creating Your First Cohort

Cohorts are groups of users who share a common event or property. You define them in PostHog, then apply them to any insight or funnel.

Navigate to Cohorts and Create a New One

In your PostHog project, go to Data Management > Cohorts and click Create cohort. You'll define who belongs in this group using events, properties, or a combination of both. Give your cohort a clear name like 'Power Users' or 'Free Trial Signups' so it's easy to find later.

Define Your Cohort with Events or Properties

Choose between Event criteria (users who triggered a specific event) or Property criteria (users with specific attributes). For example, to track power users, select the purchase event and filter for purchase_value > 100. You can also combine multiple conditions with AND/OR logic to get specific. Use date ranges to define cohorts like 'users who signed up in January 2025'.

javascript
// Capture the event that feeds your cohort
posthog.capture('purchase', {
  purchase_value: 149.99,
  product_category: 'analytics',
  user_tier: 'enterprise'
});
PostHog SDK automatically ingests these properties for cohort segmentation

Set Cohort Recalculation and Save

Choose whether your cohort is static (fixed membership, snapshot in time) or dynamic (recalculates as new events arrive). For behavioral analysis, dynamic is usually better because it captures new users who meet the criteria. Name your cohort descriptively and save it.

Tip: Start with simple cohorts (one event or property) so you can validate your event tracking is working. Debug the easy ones first, then layer complexity.

Tracking Events That Feed Cohorts

Cohorts are only as good as the events and properties you track. Make sure your event taxonomy is clean and properties are consistent across all calls.

Instrument Key Events in Your App

Use the PostHog JavaScript SDK to capture events that define your cohorts. Include relevant properties so you can filter cohorts by those attributes. For example, if you want a cohort of high-engagement users, track a feature_used event with the feature name and duration spent.

javascript
// Initialize PostHog
import posthog from 'posthog-js';
posthog.init('your-api-key', { api_host: 'https://app.posthog.com' });

// Track a feature usage event with properties
posthog.capture('feature_used', {
  feature_name: 'anomaly_detection',
  duration_seconds: 1200,
  result: 'anomalies_found'
});
Include properties that you'll use to filter cohorts later

Set User Properties to Define Cohorts

Use identify() to set properties on the user that persist across sessions, like plan_type, signup_date, or region. These properties become available in the Property criteria section when building cohorts. User properties stick to the user profile and update dynamically.

javascript
// Set user properties for cohort segmentation
posthog.identify('user-123', {
  plan_type: 'pro',
  signup_date: '2025-06-01',
  region: 'US-West',
  company_size: 'SMB'
});

// Track an event with this user already identified
posthog.capture('dashboard_opened', { 
  dashboard_id: 'main_analytics' 
});
User properties sync with the cohort engine automatically

Validate Events Are Ingesting into PostHog

Go to Data Management > Events and search for your event name. Verify that events are arriving and that properties are being captured correctly. If properties are missing, check your SDK initialization and event structure. Look at recent events to confirm the data looks right.

Watch out: Property values must be consistent. If you sometimes send plan_type: 'pro' and sometimes plan_type: 'Pro', your cohort filters won't match. Use lowercase enums in your code.

Analyzing Cohorts in Insights and Funnels

Once your cohorts are defined and events are flowing, apply them to insights to compare behavior across user groups.

Apply a Cohort Filter to an Insight

Create a new Insight (or open an existing one). In the Filter section, add a cohort filter. Select your cohort from the dropdown. PostHog will show only events from users in that cohort, allowing you to measure feature adoption, engagement, or churn for that specific group.

javascript
// Hypothetical insight creation via API
const insightResponse = await fetch(
  'https://app.posthog.com/api/projects/your-project-id/insights/',
  {
    method: 'POST',
    headers: { 'Authorization': `Bearer ${apiKey}` },
    body: JSON.stringify({
      name: 'Feature Adoption by User Tier',
      filters: {
        events: [{ id: 'feature_used', name: 'feature_used' }],
        cohort_ids: [cohort_id] // Apply cohort filter
      }
    })
  }
);
const insight = await insightResponse.json();
You can also create and filter insights programmatically via the PostHog API

Compare Multiple Cohorts

To compare behavior across cohorts (e.g., free vs. paid users), add the same event as separate Series with different cohort filters. PostHog will render both lines on the same chart, making it easy to spot differences in adoption rates, engagement velocity, or churn patterns between groups.

Use Cohorts in Funnels

Open a Funnel insight and apply cohort filters to any step. For example, create a funnel for signup → first feature use → upgrade, then filter by cohorts like product_demo_attendees vs. organic_signup. You'll see conversion rates per cohort side by side, revealing which cohort drops off at each stage.

Tip: Combine cohorts with time filters to track cohort behavior over time. For example, filter for 'users who signed up in Q1 2025' and measure their feature adoption in Q2 to track how cohort quality changes.

Common Pitfalls

  • Creating cohorts with inconsistent event or property names—if you track feature_used sometimes and feature-used other times, the cohort won't capture all qualifying users
  • Using static cohorts when you need dynamic ones—a static cohort won't include new users who meet the criteria after the cohort was created, so you'll miss trending behavior
  • Not validating events in the Data Management section before building cohorts—silent failures happen when events aren't being tracked, and you won't realize your cohort is empty
  • Overcomplicating cohorts with too many AND conditions—start simple, test, then layer complexity to avoid building cohorts that match zero users

Wrapping Up

Cohorts in PostHog let you segment users by behavior and properties, then measure how different groups engage with your product. With clean event tracking and thoughtfully designed cohorts, you'll spot trends that aggregate metrics hide. If you want to track cohort behavior automatically across all your analytics 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