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
- Open Experiments and click Create your first experiment
- Enter an experiment name and a feature flag key
- Continue to the variant rollout and review control and test
- Continue to analytics and click Add primary metric
- Choose Single-use and pick the task_created event
- Create the metric, then click Save as draft
Interactive 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
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.
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.
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.
Step 4
Continue to variant rollout
Click Continue to move to the second step of the wizard, where you decide who sees which variant.
Step 5
Continue to analytics
Check the variants. control and test each get 50% by default. Click Continue to open the Analytics step.
Step 6
Add a primary metric
Under How to measure impact?, click Add primary metric. This is the metric that tracks your main hypothesis.
Step 7
Choose Single-use
In Choose metric source, pick the single-use option to create a metric specific to this experiment.
Step 8
Pick the task_created event
In Create experiment metric, open the event picker and select task_created from the suggested events.
Step 9
Create the metric
Leave the goal as Increase and click Create. The metric is added to the experiment.
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.
Related guides
Continue with more step-by-step guides for getting work done.
How to create a multivariate feature flag in PostHogCreate a multivariate feature flag in PostHog: set a unique flag key, choose the Multivariate type, name two variants at 50/50, and save the flag.
How to create a feature flag in PostHogCreate a boolean feature flag in PostHog: set a key and description, release it to 100% of users, and save it so your app can toggle the feature.
How to add an insight to a dashboard in PostHogAdd a saved PostHog insight to a dashboard in a few clicks: open it from All insights, choose Add to dashboard, and pin it to your overview.
How to create an action in PostHogLearn how to create an action in PostHog that groups events like task_created and task_completed under one name using match groups.
How to duplicate a dashboard in PostHogDuplicate a PostHog dashboard from the Dashboards list in three steps: open the row menu, choose Duplicate, and confirm to create a copy of it.
How to export an insight to CSV in PostHogExport a PostHog insight as a CSV file in three steps: open the saved insight, click Export under Detailed results, and choose the .csv file type.
Create interactive demos like this one — free, no coding required.
Start for free →