Feature Flags

Learn how Feature Gates, also known as feature flags, let you change the behavior of your product in real time without deploying new code.

Feature flags let you change the behavior of your product in real time without deploying new code. In Statsig, feature flag is the umbrella term for any configuration you change this way, including Feature Gates and Dynamic Configs. A Feature Gate is a Boolean flag that returns true or false for each user, and it's the most common type of flag. This page covers Feature Gates.

Developers often use Feature Gates to turn on certain features for a small percentage of the total user base. This approach enables safer, gradual software releases because you can monitor the impact on system behavior. Feature Gates also let you limit application behavior for a specific set of users, such as testing different environments.

Illustration of a Feature Gate with separate targeting rules for iOS and Android users

Use feature flags when you want to:

  • Schedule gradual feature rollouts and safely deploy new code.
  • Set up dev staging environments before code hits production.
  • Have an emergency disable switch that lets you immediately turn off a particular code branch for users in your production environment.
  • Modify your user's experience based on attributes like username, email, or other identifiers.
  • Change app behavior based on context like device, browser type, version, and other environment attributes.

Don't use feature flags if:

  • You need to return structured or multi-value data based on targeting rules and conditions. Use a Dynamic Config instead.
  • You want to test complex hypotheses beyond simple A/B tests and launch impact. Set up an Experiment instead.

How it works

  1. Create a Feature Gate with targeting rules in the Statsig console.
  2. In your product code, confirm the gate, by name, with a Statsig SDK. If your product doesn't yet an SDK, install a Statsig SDK before you continue with your Feature Gate. The SDK queries the gate value at runtime and returns a true/false result based on user attributes, environment data, and other conditions you define.
  3. For finer targeting control, set up Feature Gate overrides to allow specific users to bypass the gate.
  4. Test a Feature Gate to confirm it behaves as expected before rolling it out.
  5. After your Feature Gate is live, view Feature Gate exposures in the Statsig console to monitor who encounters your gate.
  6. Set up deprecation rules and clean up old flags by managing Feature Gate lifecycles.

Key capabilities

Feature Gates offer these key capabilities:

  • Scheduled rollouts: Gradually deploy a feature over time by setting up a Feature Gate as a Scheduled Rollout.
  • Overrides and bypass lists: Use Overrides to let a specific list of users bypass your gate.
  • Chained flag dependencies: Chain Feature Gates in parent-child or other dependent relationships so a top-level gate can turn all its dependent flags on or off at once. This is useful for global disable switches that guard sub-features.
  • Built-in A/B tests: Run simple A/B tests without additional setup on the gate's Metric Impact tab. Users who see the new feature are the "treatment" group, and gated users who don't see it yet are the "control" group.
  • Feature Gate testing: Test your Feature Gates with Statsig's built-in tools to check whether each gate targets the right people.

FAQs

Was this helpful?

For AI agents: a documentation index is available at /llms.txt. Append .md to any page URL for markdown, or send Accept: text/markdown.

On this page