What is a feature flag (feature gate)?
A feature flag is a mechanism for teams to configure what system behavior is visible to users without changing application code. You might also hear them called flippers, toggles, or (at Statsig), gates.
In the Statsig UI and SDKs, we refer to what most customers know as feature flags as feature gates, as they act as a "gatekeeper" to new features. Outside of this intro, we'll refer to them as "gates".
When to use feature flags
Feature flags are commonly used as on/off switches to turn a certain system behavior on or off in production. Teams often use feature flags to turn on certain features or behavior for a small percentage of the total user base. Teams may do this to gradually ramp up a software release across their user base to limit the impact of any unanticipated system behavior, or to enable a restricted behavior only for a specific set of users.
Statsig offers several built-in capabilities with feature flags:
- A feature flag can be a simple kill switch that you can use to turn off a particular code branch for all your users
- You can use a feature flag to target newly coded system behavior to a specific set of users to implement whitelisting
- You can create user targeting rules based on Statsig-derived environment attributes such as location, client device, browser type, and client app version
- You can create user targeting rules based on user attributes such as email and user ID that you provide
- Each feature flag offers built-in A/B testing with no additional effort so you can automatically see how your feature is performing in production compared to the default or control
- A feature flag may depend on other targeting gates that control when it’s active; for example, you can create a feature flag as a top level kill switch that activates child feature flag that depend on it
The following tutorials show how you can perform common tasks with feature gates.