How to target a feature flag to a cohort in PostHog

Learn how to target a PostHog feature flag to a cohort: open the flag, edit its release condition, add a cohort filter, and save the change.

Quick answer

To target a PostHog feature flag to a cohort, open the flag from the Feature flags list, click Edit, and add a filter to the release condition. Search for the cohort, choose it from the Cohorts results, then click Save. The condition now matches only people in that cohort, at the rollout percentage.

Steps at a glance

  1. Open the flag from the Feature flags list.
  2. Click Edit.
  3. Click Add filter in the release condition.
  4. Search for and choose your cohort.
  5. Click Save.

Interactive demo

Loading demo…

Summary

A cohort filter limits a feature flag to a saved group of people instead of everyone. Release a feature to one group, such as paying customers, before it reaches the rest of your users.

Step-by-step guide

  1. Step 1

    Open the feature flag

    Go to Feature flags and find the flag in the list. Click its name to open the flag overview.

  2. Step 2

    Click Edit

    On the flag page, click Edit at the top. The release condition becomes editable.

  3. Step 3

    Add a filter to the release condition

    Under the release condition, click Add filter next to the match filters. A search box opens.

  4. Step 4

    Choose the cohort

    Type part of the cohort name in the search box. Pick the result listed under Cohorts, here Team plan users. The condition now reads as a filter on that cohort.

  5. Step 5

    Save the flag

    Click Save at the top of the page. The release condition now shows the cohort filter and an updated estimate of how many users it reaches.

Why this matters

You are shipping a new layout and only want one customer group to see it first. Adding a cohort filter to the flag's release condition keeps everyone else on the current experience while you watch how that group responds.

Frequently asked questions

  • Does the cohort filter replace the rollout percentage?

    No. The release condition keeps its rollout percentage, so the flag reaches that share of the people in the cohort.

  • Do I need to create the cohort first?

    Yes. The search only offers cohorts that already exist in the project.

Create interactive demos like this one — free, no coding required.

Start for free →