Creating an experiment

Last updated:

|Edit this page

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 presents you with a form where you can complete the details of your new experiment:

How to create an experiment in PostHog

Here's a breakdown of each field in the form:

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.

The feature flag will be created for you automatically. Therefore, you must add a feature flag key which does not exist yet.

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 if you like.

Participants are automatically split equally between variants. If you want assign specific users to a specific variant, see the section below on distribution and release conditions.

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.

Experiment goal

Setting your goal metric enables PostHog to calculate the impact of your experiment and if your results are statistically significant. You can select between a trend or conversion funnel goal.

Distribution and release conditions

By default, your experiment will target 100% of participants. If you want to target a more specific set of participants or change the rollout percentage, you need to do this by changing the release conditions for the feature flag used by your experiment.

You can do this by clicking on the Manage distribution or Manage release conditions button after saving your experiment as a draft.

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

Questions?

Was this page useful?

Next article

Creating a no-code web experiment

🚧 Note: No-code web experiments are currently considered in beta . To access them, enable the feature preview in your PostHog account. You'll also need to define disable_web_experiments: false in your Posthog web snippet configuration. We are keen to gather as much feedback as possible so if you try this out please let us know. You can email daniel.b@posthog.com , send feedback via the in-app support panel , or use one of our other support options . No-code web experiments enable you…

Read next article