How to run an A/B test
This guide shows you how to split your traffic with a feature flag and read the result in your application.
Read About feature flag allocation first. The point at which you read the feature flag decides when a visitor enters the test.
1. Create the feature flag
- Open your project.
- Click Feature flags in the sidebar.
- Click New feature flag.
- Enter a name.
- Click Create feature flag.
You cannot change the key after you create the feature flag.
2. Set the allocation
Open the detail page of the feature flag and set these controls:
- Turn Enabled on. A feature flag that is off allocates nobody.
- Set Weight to the percentage of visitors that you want in the test.
- Enter a Description that says what the feature flag tests.
3. Read the feature flag in your application
See How to read a feature flag. Read it at the point where the decision matters, and not at startup.
4. Change the weight later
- Change Weight on the detail page.
- Increment the version.
The new weight then applies to a visitor with a cached decision. Leave the version as it is to apply the new weight only to a visitor who is not allocated yet.
Related
- About feature flag allocation — why two feature flags at the same weight give four groups, not two.
- Feature flags — the controls.
