Create a feature flag
Amplitude Academy
Manage Feature Flags and Rollouts Using Amplitude
Learn how to manage feature flags and release them to targeted audiences. Use Amplitude to create, roll out, monitor, and roll back your product features.
Get startedIn Amplitude Experiment, a flag enables or disables a function or feature in your product without redeploying code. Flags drive both experiments and feature rollouts. Use flags to launch experiments and end them after you collect enough data, or to roll out new features and roll them back quickly when needed.
Amplitude offers this feature to users on all plans.
This article explains how to create a flag for a feature rollout. For information on how to use flags in your experiments, refer to rolling out your experiment to your users.
Migrate your flags from Optimizely
Migrate your flags from Optimizely into Amplitude. Contact your Amplitude representative or Amplitude Support to start the process.
Create a new flag
Before you create a flag, create a deployment and either install the SDK or configure the evaluation REST API. Then follow these steps:
- Navigate to Experiment > Feature Flags in the left sidebar and click Create A Feature Flag.
- In the Create Flag modal, choose the project for this flag from the Projects drop-down menu. Enter a name for your flag. Experiment generates the flag key from the name. The flag key identifies the flag in your codebase.
- Specify the evaluation mode for your experiment: Remote (Amplitude evaluates the flag on Amplitude's servers) or Local. Then specify the bucketing unit for this experiment.
The best bucketing unit is usually the user. In some B2B use cases, you might use company ID or city as the bucketing unit. For example, bucketing by company ID ensures that all users in a company have the same experience. Confirm the Stable Unit Treatment Value Assumption holds for whichever unit you choose.
- Click Create. Experiment opens a blank template for your flag.
- Choose the deployment for your experiment from the Deployment drop-down menu. For more information about deployments, refer to configuring Amplitude Experiment.
- Click Advanced Settings to change the bucketing salt.
Changing the bucketing salt can cause users to switch between variants in your experiment. Amplitude recommends that you don't change the bucketing salt without guidance. For more information, refer to How randomization works in Amplitude Experiment.
- In the Settings section, click the Add icon in the Variants section to add a variant. Flags must have at least one variant. A variant is the new feature or product experience you roll out to users. You can add as many variants as you need to a feature flag.
- Enter a name, value, and description for your variant. Amplitude Experiment generates the variant value from the name. The variant value is a string you use as a flag in your codebase. Click Apply.
Don't name your variants OFF. Amplitude Experiment reserves this name for fallbacks (for example, the user segment not included in your experiments).
Roll out a new feature
After you create the flag, use it to roll out a new feature.
In the Assignment panel, define the user segments that receive your new feature and specify the rollout percentage.
Define a user segment to limit your rollout to users in a specific geographic location, users in certain demographic groups, or users who meet certain usage thresholds (for example, power users).
To define a user segment, scroll to the Rule Based User Segments section and click Segment 1. Follow the same steps you use to build a user segment in Amplitude Analytics.
All Amplitude user properties and cohorts are available for defining user segments. You can include any number of user segments.
Set the rollout percentage for this feature. This is the percentage of users in the flag's user segments who receive the new feature. To give everyone in the user segment access, set this value to 100%.
Set the percentage for each variant to define how many users receive each one. Percentages must sum to 100%. For example, if you set variant A to 20% and variant B to 80%, four times as many users receive variant B as receive variant A.
Set separate rules for users not covered by any segment you created. For example, to limit the rollout to the cohorts you targeted, scroll to the All Other Users section and set the rollout percentage to zero.
Save your flag and QA it before you set it to Active. For more information, refer to QAing before launching an experiment. Your feature is live for the user segments you selected.
Was this helpful?