> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # From flag to experiment – Feature Flags pocket guide Canonical URL: https://posthog.com/learn/feature-flags/pocket-guide/flag-to-experiment > **Cloud region:** This page uses US Cloud hosts. For an EU Cloud project, use `https://eu.posthog.com` instead of `https://app.posthog.com` (app host for links). ## On this page - [The four parts of an experiment](#the-four-parts-of-an-experiment) - [The population lives in the release conditions](#the-population-lives-in-the-release-conditions) - [Exposure happens at the check](#exposure-happens-at-the-check) - [Ship the winner, then remove the flag](#ship-the-winner-then-remove-the-flag) Chapter 06 # From flag to experiment – Feature Flags pocket guide A rollout asks whether a change is safe. An [experiment](https://posthog.com/docs/experiments.md) asks whether it's better. A flag with `control` and `test` variants splits people between two versions, but the split alone measures nothing. An experiment adds the parts that turn a split into an answer. ## The four parts of an experiment | Part | The question it answers | For `new-checkout` | | --- | --- | --- | | Hypothesis | What do you expect to change, and why? | A one-page checkout will convert better than the three-step one | | Eligible population | Who can be in it? | Signed-in people who reach checkout | | Primary metric | What number decides it? | Checkout conversion rate | | Exposure moment | When does a person count as in it? | When the checkout page decides which version to render | Write the hypothesis and pick the primary metric before you start, so the result can't be read to fit whatever happened. The other two parts live on the flag. ## The population lives in the release conditions The experiment's flag decides who's eligible, the same way a rollout does. An experiment needs a multivariate flag with at least two variants, one of them named `control` Fig. 1. Use an existing flag that has those, with `control` as its first variant, or let the experiment create one. Variants A multivariate flag answers with a variant key instead of true or false. Variant key1DescriptionRollout2 A control Three-step checkout 50% B test One-page checkout 50% Add variant Fig. 1 – The variants on new-checkout: control keeps the three-step checkout, test gets the one-page version. Keep each person in one variant for the whole experiment. By default, a person exposed to more than one variant is left out of the results entirely, so every switch shrinks your sample. Switching happens when the distinct ID changes between checks. Call `identify()` before the first check, or turn on flag persistence across authentication so the variant survives login. ## Exposure happens at the check A person counts as exposed when a `$feature_flag_called` event comes in, and your flag checks already send it. Only exposed people count in the results, and anything they did before exposure is ignored. So put the check where the experience splits, after every other condition. An earlier check counts people who never see the change as exposed, and they dilute your results. A check on the checkout page counts people who saw a checkout. A check on the home page counts everyone who visited. ## Ship the winner, then remove the flag When the primary metric has an answer, roll the winning variant out to everyone, and then [clean up the flag](https://posthog.com/learn/feature-flags/pocket-guide/cleanup.md): an experiment flag is temporary by design. [Create an experiment](https://app.posthog.com/experiments) See also: [Creating an experiment](https://posthog.com/docs/experiments/creating-an-experiment.md) · [Exposures](https://posthog.com/docs/experiments/exposures.md) · [A software engineer's guide to A/B testing](https://posthog.com/product-engineers/ab-testing-guide-for-engineers.md) · [Prevent flashing during A/B tests](https://posthog.com/tutorials/prevent-fouc-ab-tests.md)