How to Filter by Cohorts in autoplay

1 min read
💡
First you need to create the cohorts in posthog and then Autoplay will automatically pull them in.

Below is an example for tracking a cohort of new users

Here is the original posthog article: https://posthog.com/tutorials/track-new-returning-users#completed-event-for-the-first-time-cohort

Creating a cohort for tracking new users

The first and easiest is creating a cohort where the users completed an event (such as pageviews, identify, or a custom event) for the first time. To set this up, go to the cohort tab, click new cohort, enter a title and description, then choose "completed an event for the first time" with your event and recency.

You can then use this cohort of new users for further analysis.

Note: since this is a behavioral cohort (based on events), this cohort won’t work with feature flags.

Manually set person property

If neither of these works for you, you can set up a person property manually in a custom event.

For example, when a user first uses your API, set their creation date in their person properties. To do this, you can capture an event at the same time, and use the $set_once property like this:

Python

posthog.capture(
    'phc_HVcGJdGDtkcvV1qUuz5bDrMf987gskGUpFH1nV6ufov',
    event='new_user_created',
    properties={ '$set_once': { 'created_at': '2023-04-24T22:02:02' } }
)

This is especially useful for projects that are on the backend, not using autocapture, or not using posthog-js, or have many custom events.

Did this answer your question?