> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # Cohorts Canonical URL: https://posthog.com/docs/data/cohorts > **Cloud region:** This page uses US Cloud hosts. For an EU Cloud project, use `https://eu.posthog.com` instead of `https://us.posthog.com` or `https://app.posthog.com` (app host for links). ## On this page - [What are cohorts?](#what-are-cohorts) - [Where can you use cohorts?](#where-can-you-use-cohorts) - [How are cohorts different from groups?](#how-are-cohorts-different-from-groups) - [How to create a cohort](#how-to-create-a-cohort) - [Static and dynamic cohorts](#static-and-dynamic-cohorts) - [Copying a cohort to another project](#copying-a-cohort-to-another-project) - [Viewing cohort history](#viewing-cohort-history) - [FAQ](#faq) ## What are cohorts? Cohorts enable you to easily create a list of users who have something in common, such as completing an [action](https://posthog.com/docs/data/actions.md) or having the same [property](https://posthog.com/docs/product-analytics/person-properties.md). Here are a few examples of the cohorts you can create: - Users who work at the same company. - Users who used your app in the last week. - Users who churned from your product. - Users who signed up recently. - Users who viewed the signup page, but didn't convert. Your cohorts are available in the [People](https://us.posthog.com/persons) page under the [Cohorts](https://us.posthog.com/cohorts) tab. > **Note:** Cohorts rely on [person properties](https://posthog.com/docs/product-analytics/person-properties.md), so you need to capture identified events to create them. To build cohorts on data from another system, such as a plan tier or a renewal date, map that table onto person properties with [warehouse properties](https://posthog.com/docs/data-warehouse/warehouse-properties.md) first. ## Where can you use cohorts? You can use cohorts in many different ways, such as: - As a filter in [trends](https://posthog.com/docs/product-analytics/trends/overview.md), funnels, retention, user paths, stickiness, and lifecycle insights - As a [breakdown](https://posthog.com/docs/product-analytics/trends/breakdowns.md) dimension in trends and funnels - As a filter on any product analytics dashboard - To target feature flags, experiments, and user surveys - To filter the session replay list and create playlists - Filter live events on the [activity page](https://posthog.com/docs/activity.md) - Filter users on the People page - To [filter out internal and test users](https://posthog.com/tutorials/filter-internal-users.md) in test account filters > **Note:** Cohorts used in [CDP](https://posthog.com/docs/data-pipelines.md) destination filters must contain **exclusively person property filters**. Person-property-only cohorts are automatically inlined and work in real-time CDP destinations. Cohorts with behavioral filters or no properties defined will cause CDP destinations to error. All cohort types work for analytics queries (insights, dashboards). You can use cohorts to answer questions like: - "Are people at company X using our app frequently?" - "What percentage of the users who signed up last week are still using our app?" - "Which features are power users using the most?" ## How are cohorts different from groups? Cohorts are sometimes confused with [groups](https://posthog.com/docs/product-analytics/group-analytics.md), but they each serve different purposes: - **Cohorts** represent a specific set of users – e.g., a list of users whose email ends with a certain string (like a company's domain). - **Groups** aggregate events based on entities, such as organizations or companies, but do not necessarily connect to a user. They enable you to analyze trends, insights, and dashboards at an entity-level (like a company or organization), as opposed to a user-level. If your only goal is to create a **list of users** with something in common, we recommend cohorts instead of groups. Groups require additional code in your app to set up, while cohorts are created in PostHog and don't require additional code. This makes cohorts easier to use and quicker to get started. ## How to create a cohort Once you've captured identified events, there are several ways to create a new cohort: ### Method 1: Create a new cohort directly from an insight You can create cohorts using data from insights such as trends, [funnels](https://posthog.com/docs/product-analytics/funnels.md), [user paths](https://posthog.com/docs/product-analytics/paths.md) and [lifecycles](https://posthog.com/docs/product-analytics/lifecycle.md). 1. Go to [insights](https://us.posthog.com/insights) and open any insight that's aggregated at a user-level, like `unique users` or `weekly active user`. 2. Click a data point in the visualization to view the [persons](https://posthog.com/docs/data/persons.md) represented in the underlying data. 3. In the modal popup, click **Save as cohort** at the bottom. The video below shows how to create a new cohort from a trend, although you can similarly create a cohort from a funnel, user path, or any other insight. ### Method 2: Create a new cohort from the cohorts page 1. Navigate to the [People](https://us.posthog.com/persons) page within the sidebar, then click on the [Cohorts tab](https://us.posthog.com/cohorts). 2. Click **\+ New Cohort** on the top right. ![left hand navigation for cohorts](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/features/cohorts/cohorts-page-light-mode.png) ### Method 3: Create a cohort using AI and MCP You can create and manage cohorts using AI agents through the PostHog [MCP server](https://posthog.com/docs/model-context-protocol.md). Ask your AI agent to create, list, retrieve, update, or delete cohorts and it uses the appropriate MCP tools. For static cohorts, you can also ask the agent to add or remove persons by their UUIDs. Example prompts: - "Create a dynamic cohort called 'power-users' for users who completed the purchase event more than 5 times" - "Create a static cohort called 'beta-testers' that I can manually add users to" - "List all cohorts in my project" See the [MCP documentation](https://posthog.com/docs/model-context-protocol.md) for setup instructions and the full list of available tools. ### Method 4: Create a cohort from Replay Vision scanner results If you use [Replay Vision](https://posthog.com/docs/replay-vision.md), you can save the users affected by a scanner's findings as a static cohort. This is useful for targeting those users with surveys, checking their retention, or excluding them from experiments. 1. Go to [Replay Vision](https://app.posthog.com/replay-vision) and open any scanner. 2. On the scanner's **Overview** tab, save the cohort: - **Monitors** – in the **Verdict mix** section, click **Save as cohort** on the verdict row you want (**Yes**, **No**, or **Inconclusive**, which shows only when the scanner has inconclusive results). - **Classifiers** – click the **Save as cohort** icon button next to a category. - **Scorers** – there is no button. Use the API or the `vision-scanners-affected-cohort-create` [MCP](https://posthog.com/docs/replay-vision/mcp.md) tool with `min_score` and/or `max_score`. The cohort is a dated snapshot: it captures the users matched in the trailing window (default 30 days) and won't live-update as new observations come in. Calling it again creates a new cohort. See [scanner types](https://posthog.com/docs/replay-vision/scanner-types.md) for details on what counts as "affected" for each type. > **Note:** Cohort creation from scanners is capped at 10,000 users per request. Scorers require a score threshold, and summarizers don't support cohorts. ## Static and dynamic cohorts You have two options when creating a cohort: 1. **Static cohorts**, lists of users that don't change over time (unless you update them manually). For example, all the users who signed up to your app in January 2024. 2. **Dynamic cohorts**, which are automatically updated based on a specific condition – e.g. all users who have performed a specific event or action in your app. ### Static cohorts Static cohorts are created from insights, by uploading a CSV of users, by selecting users individually, by duplicating a dynamic cohort, by defining criteria for a one-time snapshot, or from [Replay Vision](https://posthog.com/docs/replay-vision.md) scanner results. When creating cohorts from CSVs, the [person profile](https://posthog.com/docs/data/persons.md) associated with each row must already exist in PostHog. You can identify users using either: - **Distinct IDs**: The identifiers you send to PostHog (e.g., email addresses, user IDs from your system) - **Person IDs**: PostHog's internal unique identifiers for persons (useful when exporting data from PostHog or other analytics tools) - **Emails**: Email address of the person You can upload CSV files in two formats: **Single-column CSV**: Include one identifier per row. For distinct IDs, no header is necessary (for backwards compatibility): ```csv user123 user456 test@example.com ``` If you identify users with Person IDs, include a header (`person_id`, `person-id`, or `Person .id`): ```csv person_id 01234567-89ab-cdef-0123-456789abcdef fedcba98-7654-3210-fedc-ba9876543210 11111111-2222-3333-4444-555555555555 ``` And, if you identify users with Emails, include a header (`email`, or `e-mail`) ```csv email john@example.com jane@example.com ``` **Multi-column CSV**: Include a header row with a column containing the user identifiers. Supported column headers are: - `distinct_id` or `distinct-id` for distinct IDs - `person_id`, `person-id`, or `Person .id` for person IDs - `email`, or `e-mail` for emails ```csv email,distinct_id,name,segment user1@team.com,user123,Alice Johnson,premium user2@team.com,user456,Bob Smith,standard user3@team.com,test@example.com,Carol Davis,premium ``` Using person UUIDs: ```csv email,person_id,name,segment user1@team.com,01234567-89ab-cdef-0123-456789abcdef,Alice Johnson,premium user2@team.com,fedcba98-7654-3210-fedc-ba9876543210,Bob Smith,standard user3@team.com,11111111-2222-3333-4444-555555555555,Carol Davis,premium ``` Or using emails: ```csv email,name,segment user1@team.com,Alice Johnson,premium user2@team.com,Bob Smith,standard user3@team.com,Carol Davis,premium ``` For multi-column files, PostHog will extract the user identifiers from the specified column and ignore all other columns, making it easy to upload exported cohort data without modification. **Column precedence rules:** - If both `distinct_id` and `person_id` columns exist, the `person_id` column takes precedence - For single-column uploads without matching headers, PostHog assumes distinct IDs (backwards compatibility) To update the list, you can upload another CSV to add more users. You can also remove users by deleting their [person profile](https://posthog.com/docs/data/persons.md) from the list, noting that this will completely remove the person from PostHog. **Upload limits:** CSV uploads are limited to **20 MB** and **1,000,000 rows**. Files exceeding either limit are rejected, and no cohort is created or modified. If you have a larger file, split it into smaller parts and upload them one at a time. Uploading a CSV to an existing static cohort adds to the list rather than replacing it. Self-hosted users can adjust these limits using the `COHORT_CSV_UPLOAD_MAX_BYTES` and `COHORT_CSV_UPLOAD_MAX_ROWS` environment variables. #### Create a static cohort from criteria When creating a new static cohort, you can choose how to populate it using the **Populate from** dropdown: - **Criteria · One-time snapshot** – Define matching criteria like you would for a dynamic cohort. When you save, PostHog snapshots all people currently matching those criteria into the static cohort. The list is fixed at creation time and won't update as people change. - **Upload or add people** – Manually add people by uploading a CSV file or selecting them individually. This is useful for use cases like survey targeting, where you want a fixed snapshot of people matching certain criteria at a point in time. > **Note:** Once a static cohort is created from criteria, the criteria are locked and can't be edited. To use different criteria, create a new cohort. ### Dynamic cohorts Some dynamic cohorts also qualify as [realtime cohorts](https://posthog.com/docs/data/realtime-cohorts.md), currently in beta, which PostHog keeps up to date as events arrive so feature flags can target them. Dynamic cohorts can be based on existing cohorts, and support the following criteria: #### Behavioral | **Event or action** | **Example** | | --- | --- | | Completed event or action | Completed `user signed up` in the last 30 days | | Did not complete event or action | Did not complete `user signed up` in the last 2 months | | Completed event or action multiple times | Completed `watched video` 5 times in the last 2 weeks | | Completed a sequence of events or actions | Completed `user signed up` in the last 5 days followed by `watched video` within 1 day of the initial event | | Did not complete a sequence of events or actions | Did not complete `user signed up` in the last 5 days followed by `watched video` within 1 day of the initial event | You can select `days`, `weeks`, `months` or `years` time ranges here. #### Person properties Has or doesn't have a person property with the following operators: | **Operator** | **Example** | | --- | --- | | `equals` or `does not equal` | `Pineapple on pizza` property `does not equal` "true" | | `contains` or `does not contain` | `Job title` property `contains` "engineer" | | `starts with` or `does not start with` | `$initial_current_url` property `starts with` "[https://app."](https://app.%22) | | `ends with` or `does not end with` | `email` property `does not end with` "@gmail.com", "@yahoo.com", "@hotmail.com" | | `matches regex` or `does not match regex` | `Country code` property `matches regex` "us\|uk\|aus" | | `greater than` or `greater than or equal to` | `Age` property `greater than` "21" | | `less than` or `less than or equal to` | `Age` property `less than or equal to` "21" | | `is set` or `is not set` | `UTM Source` property `is not set` | | `between` or `not between` | `Age` property is between "18" and "30" | | `minimum` or `maximum` value | `Organization size` property has a `minimum` of "5" | For a complete list of all available operators, including semver operators for version-based filtering, see the [property filter operators reference](https://posthog.com/docs/data/property-filters.md). #### Lifecycle | **Criteria** | **Example** | | --- | --- | | Completed an event for first time | Completed `shared insight` event for the first time in the "last 30 days" | | Completed an event regularly | Completed `shared insight` at least "3 times per week" for at least "3 of the last 5 periods" | | Stopped doing an event | Stopped doing `shared insight` event in the "last 5 days" but had done it in the "5 days prior" | | Started doing event again | Started doing `shared insight` event in the "last 5 days" but had not done it in the "5 days prior" | You can select `days`, `weeks`, `months` or `years` time ranges here. ## Copying a cohort to another project You can copy a saved cohort to another project in the same organization. This option shows only when your organization has more than one project. 1. Open the cohort you want to copy. 2. Open the actions sidebar. 3. Click **Copy to another project**. 4. Select the destination project. 5. If the page lists dependencies, choose **Copy** or **Use existing** for each one. 6. Click **Copy**. The original does not change, and the copy does not sync with it. ## Viewing cohort history You can view the edit history of any saved cohort by clicking the **History** tab on the cohort's page. The history log shows who made changes, what changed, and when. Tracked changes include cohort creation, deletion, name and description edits, matching criteria updates, type changes, and manual person additions or removals on static cohorts. This is useful for auditing changes to cohort criteria over time or identifying when a cohort was last modified. > **Note:** The **History** tab only appears on saved cohorts. For more details on activity tracking across PostHog, see the [activity logs](https://posthog.com/docs/settings/activity-logs.md) documentation. ## FAQ ### How often are dynamic cohorts updated? Dynamic cohorts are updated once every 24 hours. ### Can you use a dynamic cohort as a feature flag target? You cannot use dynamic cohorts that include behavioral or lifecycle criteria as a feature flag target. To target these users for a feature flag, A/B test, or survey, you can either duplicate the dynamic cohort as a static cohort or create a new static cohort directly from criteria using the **Criteria · One-time snapshot** option. Dynamic cohorts with only person property criteria can be used directly. This is changing. [Realtime cohorts](https://posthog.com/docs/data/realtime-cohorts.md) let feature flags target cohorts built from simple event criteria, such as "completed `signed up` in the last 30 days". They're in early beta and rolling out gradually, so they aren't available in most projects yet. ### Can you use groups in cohorts? Not yet, but we are working on [rewriting cohort calculations in SQL](https://posthog.com/teams/product-analytics.md#roadmap) which will unlock your ability to do this. ### Further reading - [How to track new and returning users in PostHog](https://posthog.com/tutorials/track-new-returning-users.md) - [How to identify and analyze power users](https://posthog.com/tutorials/power-users.md) - [How to filter out internal users](https://posthog.com/tutorials/filter-internal-users.md)