Quick answer
Feature flagging wraps a feature in a conditional switch that can be changed at runtime, so code can be deployed first and released later, to a small share of users, and rolled back without a new deploy.
Formula: on if hash(flag_key + user_id) mod 100 < rollout_percent
What is feature flagging?
Feature flagging is a technique where a feature is wrapped in a conditional check, so it can be switched on or off at runtime without deploying new code. A feature flag (also called a feature toggle) is that switch: a named value, usually stored outside the code, that the application reads when it decides which path to run.
The core idea is to separate two events that used to be one: deploying code (it reaches production) and releasing a feature (users can see it). With a flag, the code ships turned off. Releasing is then a configuration change that can be done in seconds, for 1% of users, one country or one account, and undone just as fast.
In its simplest form it is one line:
if flags.is_enabled("new_checkout", user_id):
show_new_checkout()
else:
show_old_checkout()
The four kinds of flags
Not every flag lives for the same time or is decided the same way. A widely cited classification by Pete Hodgson on martinfowler.com separates four kinds.
| Kind | Typical lifespan | Who decides, and when | Example |
|---|---|---|---|
| Release flag | Days to a couple of weeks | Static: same answer for everyone until the release is finished | Hide an unfinished page while the code is merged daily |
| Experiment flag | Hours to weeks, until the result is clear | Per request, based on which group the user is in | Show half the users a new pricing layout |
| Ops flag | Mostly short; kill switches can stay | Operators change it during an incident | Turn off a heavy recommendation widget when the database is slow |
| Permission flag | Months or years | Per request, based on the user | Give a paid plan access to an advanced report |
The lifespan column is the useful one. A flag built as a release flag and left in place for two years has quietly become a permission flag that nobody owns.
How a percentage rollout works
Gradual release needs one property above all: stickiness. A user who sees the new checkout today must see it tomorrow. The usual method is to hash a stable ID together with the flag name and map the result to a bucket from 0 to 99:
bucket = hash(flag_key + ":" + user_id) mod 100; the flag is on if bucket < rollout_percent
Raising the percentage from 10 to 25 keeps every user already in the 10% and adds 15 points of new users. Using the flag name in the hash means each flag gets its own independent split, so the same 10% of people are not the guinea pigs for every feature.
Sample data: 50,000 eligible users and a 10% rollout. Expected exposure is 50,000 × 10% = 5,000 users on, 45,000 off. If the logs show only 4,600 users exposed, test it: chi-square = 400² ÷ 5,000 + 400² ÷ 45,000 = 32.0 + 3.6 = 35.6, far beyond the 3.84 cutoff for one degree of freedom at the 5% level. A gap that large means the flag is being evaluated unevenly (for example, only after the page has loaded, or skipped for some browsers), and results from that rollout cannot be trusted.
Rolling out in stages, with numbers
A flag only lowers risk if you read the result before you widen it. Sample data: the new checkout flow is released in steps, with the users who keep the old flow as the comparison group.
| Stage | Users on / off | Conversion on | Conversion off | What you can say |
|---|---|---|---|---|
| 1% | 500 / 49,500 | 22 of 500 = 4.4% | 3.6% | z = 0.94, p ≈ 0.35: too few users to tell |
| 10% | 5,000 / 45,000 | 220 of 5,000 = 4.4% | 1,620 of 45,000 = 3.6% | z = 2.85, p ≈ 0.004: unlikely to be chance |
The same 4.4% versus 3.6% gap is noise at 500 users and a clear signal at 5,000. The stage plan should therefore have two kinds of checkpoints: safety checks at small stages (errors, crashes, page speed, support tickets), where problems show up quickly, and outcome checks at larger stages (conversion, retention), where the sample is big enough. The test used here is a plain two-proportion z-test; see hypothesis testing for how to read it.
The rollout comparison is also not a true experiment unless assignment is random and the groups are compared over the same dates. A flag turned on only for an enthusiastic beta group will always look good. To keep a clean baseline for months, hold some users back on purpose; see holdout group.
Feature flags, canary releases and A/B tests
The terms overlap but answer different questions.
| Technique | Question it answers | Who is in the group |
|---|---|---|
| Feature flag | Can I change behaviour without deploying? | Anyone you target |
| Canary release | Does the new version break production? | A small share of live traffic, with automatic rollback |
| A/B test | Which version performs better? | Random split, fixed before the test |
A flag is the mechanism; a canary or an A/B test is a way of using it. Many "A/B tests" are really flag rollouts without a pre-set sample size or end date.
Flag debt and other mistakes
- Never removing flags. Each flag doubles the code paths: with 10 independent flags, there are 2^10 = 1,024 possible combinations, and almost none are ever tested. Give every release flag an owner and a removal date, and delete the flag and the old code once the rollout is at 100%.
- No default when the flag service fails. Decide in advance what the code does if the flag value cannot be read, and test that path.
- Nesting flags. Flag B only means something when flag A is on. These dependencies are hard to reason about; flatten them.
- Changing the audience mid-test. Raising the percentage during a comparison changes who is in each group. Fix the split, or only compare the period after the last change.
- Measuring users who never saw the feature. Count only users who actually reached the flagged code ("exposed"), not everyone who was merely eligible, or the difference dilutes toward zero.
- Treating the flag as the experiment. Without a hypothesis, a metric and a stopping rule, a flag is just a switch.
Measuring a flagged rollout with TapCub
TapCub does not provide feature flags, rollout controls or A/B assignment; it only measures. Use it to see what the flagged users did.
- Decide the exposure event. In All-platform analytics › Data › Tracking plan, add an event such as
flag_exposedwith the propertiesflagandvariant(for examplenew_checkoutandon/off). Mark both properties required. Keep properties to the ones you will break down by. - Send it from the flagged code path. Call
tapcub.track('flag_exposed', { flag: 'new_checkout', variant: 'on' })at the moment the user actually reaches the flagged screen, not when the flag is evaluated for someone who never gets there. - Check the exposure count first. Count distinct users per variant in event analysis and compare with the split you configured (the 5,000 versus 45,000 check above). A mismatch means a delivery bug, not a result.
- Compare outcome events by variant. Break down the goal event (for example
purchase) by thevariantproperty over the same dates, then read conversion for each group. - Do the significance test yourself. TapCub shows the numbers; this article does not rely on it to say whether a gap is real, so use the formula above or a calculator.
See also: What is progressive delivery? Staged rollouts and metric gates.
See also: Server-Side Testing: How It Differs From Client-Side A/B Tests.
Sources
- Pete Hodgson, Feature Toggles (aka Feature Flags), martinfowler.com.
- OpenFeature, OpenFeature specification, Cloud Native Computing Foundation.
Was this explanation clear?
We use your answers to fix and expand this page.
Couldn’t send. Please try again in a minute.
Thanks for the feedback. We’ll use it to improve this page.You’ve already sent feedback on this page. Thanks.

Technical Engineer
Focuses on tracking code, SDKs, and API integrations, with practical guidance on implementation checks and troubleshooting.