The Full Stack Developer Guide Developer Hub

Welcome to the Full Stack Developer Guide developer hub. You'll find comprehensive guides and documentation to help you start working with the Full Stack Developer Guide as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Feature variables

Feature variables enable you to avoid hard-coding variables in your application. Instead of updating the variables by deploying, you can update 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 via an Optimizely feature variable. This enables Optimizely to dynamically assign different values you want to test for gravity to different users as part of experiment variations so you can find the right level of challenge for a game.

gravity feature variable for Flappy Bird. See [Flappy Bird video game](

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

Feature variables in experiments

You can add and configure more than one feature variable in a single experiment variation. First, configure a feature flag with several variables. Then, for each test variation, change one or more of the variable values. In the Flappy Bird example, a "difficult" 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.

Feature variables in rollouts

You can set different feature variables per audience and per environment for feature rollouts. For more information, see Introduction to rollouts

How it works

Use feature variables anywhere you might normally use a hard-coded value. It's important to ensure that:

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

You'll get the value of a feature variable in your code with something like:

gravity_value = optly.getFeatureVariable('gravity', userId).

When this feature test is live, Optimizely:

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

Note that if you edit the feature configuration for a feature test while it is running, the changes are reflected live in the running feature test.

Create a feature variable

For information on how to create feature variables, see Create feature variables.

Updated 4 months ago

Feature variables

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.