TapCub is live — analytics, insights and live chat, free on one platform
Glossary

Feature Flagging: What Feature Flags Are and How to Roll Out

Feature flagging wraps a feature in a switch so you can release it without deploying code. Flag types, percentage rollouts, a staged-rollout calculation and flag debt.

Chen Yu Reviewed by Sophia Bennett Also called feature flag Last updated Nov 19, 2026 Glossary

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.

KindTypical lifespanWho decides, and whenExample
Release flagDays to a couple of weeksStatic: same answer for everyone until the release is finishedHide an unfinished page while the code is merged daily
Experiment flagHours to weeks, until the result is clearPer request, based on which group the user is inShow half the users a new pricing layout
Ops flagMostly short; kill switches can stayOperators change it during an incidentTurn off a heavy recommendation widget when the database is slow
Permission flagMonths or yearsPer request, based on the userGive 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.

StageUsers on / offConversion onConversion offWhat you can say
1%500 / 49,50022 of 500 = 4.4%3.6%z = 0.94, p ≈ 0.35: too few users to tell
10%5,000 / 45,000220 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.

TechniqueQuestion it answersWho is in the group
Feature flagCan I change behaviour without deploying?Anyone you target
Canary releaseDoes the new version break production?A small share of live traffic, with automatic rollback
A/B testWhich 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.

  1. Decide the exposure event. In All-platform analytics › Data › Tracking plan, add an event such as flag_exposed with the properties flag and variant (for example new_checkout and on / off). Mark both properties required. Keep properties to the ones you will break down by.
  2. 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.
  3. 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.
  4. Compare outcome events by variant. Break down the goal event (for example purchase) by the variant property over the same dates, then read conversion for each group.
  5. 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

Was this explanation clear?

We use your answers to fix and expand this page.

Chen Yu

Technical Engineer

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

FAQ

Questions people ask

Short answers to the follow-up questions that come up most.

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

What is a feature flag?

A feature flag is a named switch, stored outside the code, that decides at runtime whether a feature runs. It separates deploying code from releasing a feature, so a release becomes a setting you can change and undo.

What is the difference between a feature flag and an A/B test?

A flag is the mechanism that turns behaviour on or off for chosen users. An A/B test is a way of using it: random groups, a metric and a stopping rule fixed in advance, to learn which version performs better.

How long should a feature flag live?

A release flag should live days to a couple of weeks and be deleted once the rollout reaches 100%. Ops kill switches and permission flags may last longer, but each should have an owner.

How do you measure a feature rollout?

Count exposed users per variant first and check the split matches the plan. Then compare the outcome metric for the same dates and judge the gap with a significance test, since small stages are mostly noise.

See this number on your own site

Add one script tag for web and apps, and the first reports fill in within minutes.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics