---
title: Flag variations and flag variables overview
slug: feature-experimentation/docs/flag-variations-and-flag-variables-overview
docTags: 
createdAt: 2026-08-05T20:40:01.000Z
---

- Optimizely Feature Experimentation

Flag [variations](docId\:nmipY0LAkbpzTcsggjlPn) let you avoid hard-coding variables in your application. Instead of updating the [variables](docId\:eH-UMm_rOn_GdGDGLV6__) 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](https://flappy-interactive.onrender.com/), 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. 

![301d96a-2020-04-07\_14\_53\_07-Full\_Stack\_Interactive\_Flappy\_Bird\_Demo.png](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/h8IH5QjF0rnYVzi6q9CAa-20260720-145745.png)

See [Flappy Bird video game](https://flappy-interactive.onrender.com/)

## 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.

:::hint{type="info"}
**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](docId\:eH-UMm_rOn_GdGDGLV6__) and [flag variations](docId\:nmipY0LAkbpzTcsggjlPn), see the corresponding documentation.
