How to run an A/B test in PostHog

Set up an A/B test in PostHog: name the experiment, create its feature flag, review control and test variants, add a primary metric, and save a draft.

Quick answer

Open Experiments in PostHog and click Create your first experiment. Name the test, enter a feature flag key, review the control and test variants, then add a single-use primary metric built on the task_created event. Finish by clicking Save as draft so the experiment is stored and ready to refine.

Steps at a glance

  1. Open Experiments and click Create your first experiment
  2. Enter an experiment name and a feature flag key
  3. Continue to the variant rollout and review control and test
  4. Continue to analytics and click Add primary metric
  5. Choose Single-use and pick the task_created event
  6. Create the metric, then click Save as draft

Interactive demo

Loading demo…

Summary

A PostHog experiment pairs a feature flag with a metric so you can compare variants on real users. The wizard walks through description, variant rollout and analytics, so a first-time user can set up a complete test in one pass.

Step-by-step guide

  1. Step 1

    Create your first experiment

    Open Experiments from the sidebar. On the empty page, click Create your first experiment to start the three-step wizard.

  2. Step 2

    Name the experiment

    In the What are we testing? section, click Experiment name (required) and type a clear name, such as Compact board test.

  3. Step 3

    Set the feature flag key

    Click Feature flag key (required) and enter a key, such as compact-board-test. The flag controls which users see which variant.

  4. Step 4

    Continue to variant rollout

    Click Continue to move to the second step of the wizard, where you decide who sees which variant.

  5. Step 5

    Continue to analytics

    Check the variants. control and test each get 50% by default. Click Continue to open the Analytics step.

  6. Step 6

    Add a primary metric

    Under How to measure impact?, click Add primary metric. This is the metric that tracks your main hypothesis.

  7. Step 7

    Choose Single-use

    In Choose metric source, pick the single-use option to create a metric specific to this experiment.

  8. Step 8

    Pick the task_created event

    In Create experiment metric, open the event picker and select task_created from the suggested events.

  9. Step 9

    Create the metric

    Leave the goal as Increase and click Create. The metric is added to the experiment.

  10. Step 10

    Save as draft

    Your primary metric now appears under the analysis settings. Click Save as draft to store the experiment.

Why this matters

You want to know whether a compact board layout helps people create more tasks, but guessing from gut feel is risky. Setting up the experiment with a clear metric gives you a draft you can run and judge on data.

Frequently asked questions

  • Which variants does a new experiment start with?

    The variant rollout step starts with control and test, each set to 50%. You can also add variants with the Add variant button.

  • Can I save the experiment before it is finished?

    Yes. On the Analytics step, click Save as draft once your primary metric is in place.

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

Start for free →