Personalize variations with contextual bandits (beta)
Contextual bandits learn which variation works best for each kind of user, not only which one works best overall. You personalize on attributes such as country, device, or plan. Traffic weights then adapt within each context toward one decision metric.
From one winner to a winner per segment
A multi-armed bandit shifts traffic toward a single winner for everyone. A standard experiment can show in its dimension breakdowns that segments preferred different variations. You still have to build and ship those targeting rules by hand. A contextual bandit shifts traffic within each segment during the run and keeps adapting after you would have stopped an experiment.
How it learns within each context
GrowthBook fits a decision tree over your context attributes, grouping users who share similar context. Within each group, Thompson sampling balances trying variations with sending more traffic to better performers. Every variation keeps at least a small share of traffic in each context.
- Personalize on attributes your SDK knows when it assigns a variation.
- Choose one Fact Metric as the decision metric.
- Watch current weights and per-context results on the bandit's page.
When to use one
Contextual bandits fit when you expect the best variation to differ by segment. Examples include checkout copy that lands differently by country, or a layout that helps on mobile but not on desktop. They also suit short-lived tests, such as promotional copy, when performance likely varies by context. Each segment needs enough traffic to learn, and GrowthBook pools smaller segments with similar users. For unbiased effect estimates or several outcome metrics, run a standard experiment.
Getting started
Contextual bandits are a beta feature on Enterprise plans.
- Under SDK Configuration → SDK Connections, check that the connection uses a supported SDK language and a compatible version.
- Log the context attributes used for assignment, and include matching columns in your Contextual Bandit Assignment Query.
- Create a bandit under Experiments → Contextual Bandits and link at least one feature flag. Starting the bandit automatically publishes pending drafts on its linked flags.
Follow the contextual bandit setup guide for supported SDK versions and the full launch steps.