Creating an experiment

To create a new experiment, go to the A/B testing tab in the PostHog app, and click on the New experiment button in the top right.

This opens a guided creation wizard that walks you through three steps:

  1. Description – Name your experiment, write a hypothesis, and set the feature flag key
  2. Variant rollout – Configure variants, split percentages, and rollout percentage
  3. Analytics – Set inclusion criteria and add metrics to measure impact

You can click through all steps before filling them in. Validation errors appear when you navigate away from a step or change an input. When you're done, click Save as draft or Launch to finalize.

How to create an experiment in PostHog

Here's a breakdown of each step in the wizard:

Feature flag key

Each experiment is backed by a feature flag. In your code, you use this feature flag key to check which experiment variant the user has been assigned to.

By default, the wizard creates a new feature flag for you automatically when the experiment is saved. The flag key is auto-generated from your experiment name, but you can customize it. If you already have a feature flag you'd like to use, click Select existing flag to link it instead. The existing flag must have multiple variants with 'control' as the first variant.

Advanced: It's possible to create experiments without using PostHog's feature flags (for example, if you're using a different third-party library for feature flags). For more info, read our docs on implementing experiments without feature flags.

Experiment variants

By default, all experiments have a control and test variant. You can add more variants in the Variant rollout step of the wizard. Participants are automatically split equally between variants.

If you link an existing feature flag, the Variant rollout step becomes read-only. You can adjust the flag's variants from the feature flag page after saving the experiment.

The Traffic preview shows a visual bar chart of how traffic is distributed across your variants based on your split and rollout percentage. The visualization displays the actual bucketing logic of how users are distributed in a rollout. Increasing the rollout percentage does not reassign users to other variants; however, changing the split or adding variants might lead to inconsistent experiences for users.

Participant type

By default, PostHog runs experiments at a user-level. This means that participants are assigned to a variant based on their person properties. However, if you've created groups, you can also run group-targeted experiments. This will test how a change affects your product at a group-level by providing the same variant to every member of a group.

Rollout and release conditions

By default, your experiment rolls out to 100% of participants. In the Variant rollout step of the wizard, you can adjust the Rollout percentage to limit the percentage of users included in the experiment. This is useful when you don't want to expose all users to the experiment.

For more advanced release conditions – such as targeting specific user properties, cohorts, or groups – click Manage distribution or Manage release conditions after saving your experiment as a draft. This modifies the release conditions for the underlying feature flag.

Note: If you select a server-side event, you may see a warning that no feature flag information can be detected with the event. To resolve this issue, see step 2 of adding your experiment code and how to submit feature flag information with your events.

Experiment goal warning

Community questions

Was this page useful?

Questions about this page? or post a community question.