Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

The availability of features may depend on your plan type. Contact your Customer Success Manager if you have any questions.

Dev guideRecipesAPI Reference
Dev guideAPI ReferenceUser GuideLegal TermsGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev guide

Flag variations and flag variables

An overview of flag variations and flag variables in Optimizely Feature Experimentation.

Flag variations let you avoid hard-coding variables in your application. Instead of updating the variables by deploying, you can group them in a flag variation and edit them remotely in the Optimizely app.

As an example, take the Flappy Bird video game, a game in which the variable gravity determines the difficulty of flying through oncoming gaps in pipes.

Gravity was hard-coded in the application but is now controlled remotely using an Optimizely flag variable. This lets Optimizely assign different values dynamically that you want to test for gravity to different users in different flag variations.

For example, a "difficult" flag variation could test a high gravity variable and a low pipe gap distance variable. An "easy" variation could test a low gravity and a large pipe gap distance variable. You could compare these two variations in an A/B test so you can find the right level of challenge for a game.

flappy bird example

gravity flag variable for Flappy Bird. See Flappy Bird video game

How it works

Use flag variations anywhere you might normally use hard-coded values. It is important to ensure that:

  • An Optimizely SDK client (or Agent instance) is available for that code context.
  • You pass a consistent user context.

Optimizely automatically assigns the right flag variation to the user based on the flag rules that apply to that user.

When a flag rule is live, Optimizely:

  • Assigns a user to a variation based on your defined traffic allocation and audience.
  • Returns the appropriate flag variable values to your code for that user.

📘

Note

If you edit a flag variation while a flag rule is running, the changes are reflected live.

Create a flag variable or flag variation

For information on creating flag variables and flag variations, see the corresponding documentation.