Cohorts

Last updated:

|Edit this page

What are cohorts?

Cohorts enable you to easily create a list of users who have something in common, such as completing an action or having the same property.

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 page under the Cohorts tab.

Note: Cohorts rely on person properties, so you need to capture events with person profiles to create and use them.

Where can you use cohorts?

You can use cohorts in many different ways, such as:

  • In trends, funnels, retention, user paths, stickiness, and lifecycle insights
  • 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
  • Filter users on the People page

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, but they each serve different purposes:

  • Cohorts represent a specific set of users – e.g., a list of users who's email contains 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.

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.

If your only goal is to create a list of users with something in common, we recommend cohorts instead of groups.

How to create a cohort

Once you've captured events with person profiles, there are two 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, user paths and lifecycles.

  1. Go to 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 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 page within the sidebar, then click on the Cohorts tab.

  2. Click + New Cohort on the top right.

left hand navigation for 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, or by duplicating a dynamic cohort.

The CSV file only requires a single column with the user's distinct ID. The very first row (the header) will be skipped during import.

To update the list, you can either upload another CSV to add more users, or use the interface to remove users.

Dynamic cohorts

Dynamic cohorts can be based on existing cohorts, and support the following criteria:

Behavioral

Event or actionExample
Completed event or actionCompleted user signed up in the last 30 days
Did not complete event or actionDid not complete user signed up in the last 2 months
Completed event or action multiple timesCompleted watched video 5 times in the last 2 weeks
Completed a sequence of events or actionsCompleted 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 actionsDid 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:

OperatorExample
equals or does not equalPineapple on pizza property does not equal "true"
contains or does not containemail property does not contain "gmail"
matches regex or does not match regexCountry code property matches regex "us
greater than or greater than or equal toAge property is greater than "21"
less than or less than or equal toAge property is less than or equal to` "21"
is set or is not setUTM Source property is not set
between or not betweenAge property is between "18" and "30"
minimum or maximum valueOrganization size property minimum of "5"

Lifecycle

CriteriaExample
Completed and event for first timeCompleted shared insight event for the first time in the "last 30 days"
Completed an event regularlyCompleted shared insight at least "3 times per week" for at least "3 of the last 5 periods"
Stopped doing an eventStopped doing shared insight event in the "last 5 days" but had done it in the "5 days prior"
Started doing event againStarted 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.

FAQ

How often are dynamic cohorts updated?

Dynamic cohorts are updated once every 24 hours.

Can you use a dynamic behavioral cohort as a feature flag target?

No. To target a dynamic cohort for a feature flag, A/B test, or survey, you must first duplicate it to a static cohort.

Can you use groups in cohorts?

Not yet, but we are working on rewriting cohort calculations in HogQL which will unlock your ability to do this.

Further reading

Questions?

  • River
    a month ago

    can I trigger cohort calculation on demand?

    from client side or server side api?

  • Harsh
    3 months ago

    Add user to cohort before they're created in PostHog

    Use case

    We have some feature flags that are enabled for a static cohort. For example, let's say feature is called "can see custom reporting" and it's enabled for a static cohort called "paying report partners". We're facing a cold start problem, where -

    1. The person doesn't exist on PostHog before they first login, so we can't add them to the static cohort proactively
    2. When the person logs in, they're not in the cohort and have to be added for the feature flag to work for them, creating a bad UX

    Ask

    Could we support adding people to cohorts before they're created in Posthog? Can still use person properties (ex: email) but without that person already existing.

    Happy to chat with folks on this, thanks!

  • Charlotte
    4 months ago

    Recordings of a Cohort

    I've create a cohort of users and want to learn more about their behaviors by watching their recordings. Is there a way I can make a playlist of their recordings?

  • Anton
    5 months ago

    Implementing a sequence based cohort

    I'm trying to create a cohort based on the user: completing a sequence of events or actions. I don't seem to have this option. Is there a tutorial for this?

  • Rob
    6 months ago

    Is there a limit to number of cohorts in my account?

    I'm planning some dashboards, and wondering whether a cohort-based strategy makes sense. I don't want to find out later on down the line that I can only have {x} cohorts in my account - is there a limit, if so what is it?

    • Georgiy
      6 months agoSolution

      Hi Rob – we don’t limit the number of cohorts. However, cohorts have certain limitations, such as being calculated only once per day. If you want real-time insights, we recommend using filters.

    • Rob
      Author6 months ago

      Thanks Georgiy,

      That's perfect - understood RE: daily updates, we don't expect the cohort membership to change that frequently, only the behaviour of the members, so this is a good solution for us.

      Thank you for getting back to me! :)

  • Brennan
    7 months ago

    Cohort based on data warehouse user properties?

    I want to create a cohort of paying users. In the data warehouse, I've joined the persons table to our stripe_charges tables and can use a SQL query to identify the person ids, but I can't seem to create a cohort from it.

    • Anton
      14 days ago

      I have a similar question: I want a cohort of users who have a minimum number of sessions. I can get their ids using SQL, but I can't figure out how to turn the SQL into a cohort.

  • Oliver
    9 months ago

    Add cohort membership to person and event properties

    Is there a way to add a property "cohorts" with the value being a list of all cohorts the user currently belongs to?

  • Daniel
    10 months ago

    Is it possible to use contains on a person property of type array?

    In our app, users can join a group of users we call "spaces". A user can join multiple spaces so, with the current limitations on groups in PostHog, I cannot use them. With cohorts, I could add e.g. an array to user properties ["space_id_1", ..., "space_id_n"]. Could I then create cohorts for specific spaces, using the contains operator?

    • Marcus
      10 months agoSolution

      Hey Daniel, currently we will treat arrays as strings so that you could use a filter like spaces contain space_id_1.

  • Sagiv
    a year ago

    Create cohort based on session duration

    is it possible to create a dynamic cohort for all the users who had at least 1 session with a duration over X minutes?

    • Marius
      10 months ago

      Hey Sagiv, sadly you can't currently use session durations as a factor when creating cohorts. We plan to take on the task of rewriting cohort calculation into HogQL later this quarter to add all the missing features.

  • Alexander
    a year ago

    How do I create a cohort of users that HAVE NOT been on the website in a given timeframe?

    I have cohorts set up easy enough for Users that have been on in the last day, week and month using "completed event: pageview"

    When I try to create ones for "did not complete event: pageview" I get: "Did not complete event' is a negative cohort criteria. Negation criteria can only be used when matching all criteria (AND), and must be accompanied by at least one positive matching criteria."

    What positive matching criteria should I be using to get this working?Screenshot 2024-03-28 172213.png

    • Abigail(she/her)
      10 months ago

      Hey there, I know this is an older question so maybe you've found a solution by now, but I just wanted to share my experience as well -- I ran into the same issue when setting up my cohorts, but what you can do is create a positive criteria that all of you users will fall under, like signup or a different timeline for a pageview. For example, you could filter for users who did sign up but didn't pageview within the last 30 days. Or, if you don't use signup, you could filter for users who did pageview within the last year but didn't pageview within the last 30 days. Maybe there's a better solution out there, but this worked for me!

  • Dylan
    a year ago

    How are dynamic cohorts updated?

    Are dynamic cohorts updated on some sort of schedule? Is it every 24hours or more real time? Are they cached in some way?

    I have a few cohorts which utilize the "completed an event multiple times" in 30 days criterion and I am noticing some discrepancies between multiple cohorts (some with the exact same criterion).

    I actually have one cohort, let's call it "Cohort B", that includes another cohort "Cohort A".

    I would expect Cohort B to always have equal or greater number of users as Cohort A, however Cohort B actually has less users in it currently. (I am using the "In Cohort": Cohort A criteria in Cohort B)

    • Marcus
      a year ago

      Let me know when that happens again!

  • Ann
    a year ago

    Why isn't my static CSV import working?

    I created a CSV with a header populated with new user IDs. I drag and drop the file in, then I save it. But it never updates the cohort. What can I do to troubleshoot this?

    • Neil
      a year ago

      Hmm, any of the IDs in the dropdown on persons should work, not just the username, as to us all of them are equivalent.

      Mind raising an issue through the in-app support form with an example of ID that didn't work? and a link to the person that has the ID?

      Cheers

  • John
    a year ago

    Can we create cohorts automatically for a given properties values?

    For our current use case, we'd like to create cohorts based on a reference value passed in the initial URL they access (to identify the source of how they got to our website). We can create them manually, but that seems like it will get tedious. Much better to be able to say "Create a Cohort for each unique reference value we see".

    • Daniel
      a year ago

      +1

      There used to be an automatic Cohort creator, but I can't seem to find it anywhere.

    • Juraj
      a year ago

      John, Daniel,

      We indeed used to have an automatic cohort creator that we've since deprecated in favor of group analytics.

      John: in your use case, you could have a group type called Referrer URL. For any new URL encountered, a new group would be assigned to that group type.

      See more about how to work with Groups: https://posthog.com/docs/product-analytics/group-analytics

  • Kirsten
    a year ago

    Is it possible to pass cohort information to marketo?

    Looking to use the cohort data to trigger catered trial / informational emails in marketo. For example, we have a cohort that tracks all users who created a trial and haven't taken a certain action within 48 hours. We'd like to email those users specific information at that point.

    • Li
      a year ago

      Hey Kirsten,

      We don't have in house automated processes for this but you should be able to export cohorts of user data easily!

  • Dylan
    a year ago

    Is it possible to get a notification when members of a cohort change?

    I am looking for a way to be notified when new users are added to a dynamic cohort. As I understand it these are updated every 24 hours so it could just happen on that same cadence.

    Ideally I would call a webhook - however I see webhooks only support Actions.

    Our end goal is to automate getting cohorts of users into our CRM for personalized outreach. A slack notification or something like that would be nice too.

    • Kiara
      a year ago

      I'd love to know too

  • Michael
    a year ago

    Update interval for dynamic cohorts?

    In a dynamic cohort. How often are the match persons updated?

    • Neil
      a year agoSolution

      Hey Michael, every 24 hours :)

  • Salwa
    a year ago

    Is it possible to create a dynamic cohort for users based on each Month.

    I want to create three buckets of users for each month that I can compare and observe for each calendar month. For example, users who completed an action on 3 or less than 3 days will be grouped as casual. This way I can see how the number of casual users in August compares with the no. of casual users in September. How can I use cohorts to do this. With cohorts, I would have the added advantage of filtering specific groups in insights and view the user segments for only those groups. Is there another way to visualize this?

    • Li
      a year ago

      Hi Salwa!

      We don't have specific time range on cohorts so it'll always have to be "the last X days/weeks/months"

      It might be helpful to take a look at the retention insight option as that gives a breakdown month to month at your users

  • Muh
    2 years ago

    It is possible get cohort group by belong to "group_name"

    We'd like to create cohorts which included group.

    So the result is not 'users', but 'group'. when the one of users the group is match with the criteria.

    • Li
      2 years ago

      Hey there!

      Cohorts doesn't currently support groups

    • Muh
      Author2 years ago

      Thanks Li, for your answer.

      Any roadmap to make group possible in cohorts ?

  • Guy
    2 years ago

    Is it possible to create a cohort based on a user's group attribute?

    We'd like to create a cohort which includes users, that belong to groups in which no user has done a certain action. Is that possible?

    • Li
      2 years ago

      Hey Guy,

      We don't currently support groups with cohorts. However if you have a person who has done "activated" event, you can create a cohort of users based around events, which could get you something close.

Was this page useful?

Next article

Events

An event is the core unit of data in PostHog. It represents an interaction a user has with your app or website. Examples include button clicks, pageviews, query completions, and signups. Events consist of: An event name like $pageview or query completed . Events starting with $ are PostHog defaults. A distinct_id which is a unique identifier for person , commonly a uuidv7 value like 018daf23-89b3-7cf8-a4f1-94064c96df90 A timestamp in ISO 8601 format, which is the time the event…

Read next article