• HOME
  • INTEGRATIONS
  • SDKS
  • GUIDES
  • API DOCS
No results for ""
EXPAND ALL
launchdarkly.com

EDIT ON GITHUB

Creating flag variations

Read time: 2 minutes
Last edited: Apr 01, 2021

Overview

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.

A flag's dashboard with the Variations tab called out.
A flag's dashboard with the Variations tab called out.

Understanding flag types

LaunchDarkly supports different flag types:

  • Boolean flags have two settings: true or false.
  • Multivariate flags have multiple settings that let you define different variations.

To learn more about creating flags, read Creating a feature flag.

Managing flag variations

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 true and false variations, 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.

The Variations tab with multivariate flag variations displayed.
The Variations tab with multivariate flag variations displayed.

When you add, edit, or delete a feature flag's variations, the change impacts environments within the project.

Changing variation types
After a feature flag has been created, you cannot change the type of its variations. For example, you can't edit a feature flag that returns numbers to make it return strings instead.
Deleting variations

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.

Understanding multivariate flags

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:

  • String
  • Number
  • JSON object
  • JSON array

A multivariate flag percentage rollout.
A multivariate flag percentage rollout.

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.

A multivariate flag with custom rules.
A multivariate flag with custom rules.

You can also use multivariate flags to perform A/B/n testing with LaunchDarkly's Experimentation feature. To learn more, read Creating Experiments.

Changing default flag variations

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 on and off values.

The default variation options on the flag creation screen.
The default variation options on the flag creation screen.

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.

Editing default variations only impacts new environments
If you modify a flag's default variations, the updated default variations only apply to new environments. You can not change the default variations in environments that already exist.