Creating flag variations
Read time: 2 minutes
Last edited: Apr 01, 2021
This topic explains how to use a flag's Variations tab to create and edit your feature flag's variations and outlines the different types of flag variations.
LaunchDarkly supports different flag types:
- Boolean flags have two settings:
- Multivariate flags have multiple settings that let you define different variations.
To learn more about creating flags, read Creating a feature flag.
In the Variations tab, you can add, edit, or delete variations of existing flags:
- Boolean flags: you can edit the name and description for the
falsevariations, and change the default variations for new environments.
- Multivariate flags: you can edit any variation’s value, name, and description. You can also add and delete variations for a multivariate flag. To learn more, read Understanding multivariate flags.
When you add, edit, or delete a feature flag's variations, the change impacts environments within the project.
When you delete a variation, custom rules that return that variation are also deleted. If a custom rule has a percentage rollout, the rollout for that variation is set to zero. If the default rule returns the deleted variation, it will be changed to return the
off variation instead.
Multivariate flags let you use one flag to serve multiple variations of a feature simultaneously. There is no limit to the number of variations you can add to a multivariate flag, making it useful for complex use cases and to manage two or more variations of a feature. For example, a multivariate flag that serves strings as variations can be used to enable different customer checkout types, serving a percentage rollout of those types to users.
Multivariate flag variation options include:
- JSON object
- JSON array
You can use custom rules to refine a rollout even more. In this example, the first rule serves two-click checkout to all users whose country is
USA. The second rule targets users whose email ends with
example.com and serves one-click checkout to 10%, two-click checkout to 10%, and the original checkout flow to 80% of those users. All users who are not targeted in the custom rules are served the Default rule.
To learn more about targeting rules, read Targeting rules based on user attributes.
You can also use multivariate flags to perform A/B/n testing with LaunchDarkly's Experimentation feature. To learn more, read Creating Experiments.
When you create a feature flag, some of its variations are designated as default variations. A flag's default variations are the variations that are served when a flag is on or off unless you specify otherwise.
For example, a boolean flag could have
false set as its default off variation and
true set as its default on variation. A multivariate flag could have
variation 1 set as its default off variation and
variation 2 set as its default on variation, with
variation 3 and
variation 4 configured to appear in other, more specific circumstances, such as when a user is based in a specific region or has a certain email address.
Default variations are designated automatically every time you create a feature flag. You can accept the default variations or change them. When you do this and click Save Flag, the flag is created across all environments in your project with these variations set as its
You can change a flag's default variations from the Variations tab. Update the default variations in the "Defaults for new environments" section. Subsequent environments you create also use the flag's default values. If you change the default variations and then create a new environment, however, the environment you create will use the updated default variations.