A/B Testing
Compare variants to measure impact
A/B testing splits users between variants to measure which performs better. Feature flags make this easy - configure the split in Flipswitch, measure results in your analytics.
The Pattern
Implementation
1. Create a String Flag
For A/B tests, use a string flag to identify variants:
- Key:
checkout-experiment - Type: String
- Variants:
control- Current checkouttreatment-a- New checkout designtreatment-b- New checkout with upsells
2. Configure the Split
Set up a gradual rollout:
Users are assigned deterministically by targetingKey - the same user always sees the same variant.
3. Use in Code
4. Track Conversions
Track outcomes with the variant:
5. Analyze Results
In your analytics tool, compare metrics by variant:
| Variant | Users | Conversions | Rate |
|---|---|---|---|
| control | 10,000 | 320 | 3.2% |
| treatment-a | 10,000 | 380 | 3.8% |
| treatment-b | 10,000 | 350 | 3.5% |
Treatment-a wins. Roll it out to 100%.
Statistical Validity
Flipswitch ensures even distribution, but you're responsible for statistical significance:
Sample size. Run the test long enough to collect meaningful data. A 0.5% difference with 100 users means nothing.
Consistent assignment. Users see the same variant across sessions because assignment is based on hashing their targetingKey.
One variable. Change one thing per test. If treatment-a has a new design AND new copy AND new flow, you won't know what worked.
Excluding Users
Sometimes you want to exclude certain users from experiments:
Internal users and enterprise customers always see the stable version.
Ending an Experiment
When you've decided on a winner:
- Set the winning variant to 100%
- Wait for any cached values to expire
- Remove the experiment code
- Delete the flag
Multi-Armed Bandit
For optimization over pure testing, adjust percentages as you learn:
Shift traffic toward the winning variant while still exploring alternatives.