Create flag variables
Variables let you remotely configure your flag. Instead of hard-coding and updating your variables by re-deploying, you can group them in a flag variation and update them remotely in the Optimizely Feature Experimentation application.
Flag variables let you add and configure more than one variable in a single experiment variation. For example, you can create a feature flag with several variables like color, size, and text. Then, for each variation, you can change one or more of the variable values. This lets you test different combinations of variables and measure their impact on your key metrics.
You can create flag variables of the type:
- Boolean
- String
- Integer
- Double
- JSON
Note
There is no character limit for a JSON variable value.
Examples of flag variables
General example
For example, you are running experiments and want to improve the number of interactions with a search bar on your website. You could create the following variables and their types:
- Length of the search bar – Integer
- Placeholder copy – String
- Placeholder font color – String
- Location on your page – Integer
- Searchbar visibility – Boolean
You can change the values in these variables without deploying new code. Run different experiments with different variable values to determine the optimal values.
Examples based on role
Depending on your goals and needs, flag variables can be used for various use cases. Here are some examples of different roles, how they could benefit using variables, and some examples of those variables and their type:
Marketers – Improve their conversion rates:
- Copy (headlines, banners, CTAs) – String
- Images – String or JSON
- Colors on landing pages – String
- Layout positions – Integer
Product Managers – Improve their revenue and retention:
- Different pricing – Double
- Offers – String
- Features on their product pages – String
- Icons (size, position, labels) – Integer, string, or JSON
- Colors – String
- Messaging – String
Developers – Improve their application user experience and performance:
- Components contributing to different algorithms – Depends on the variable
- Hard capped limits (for example, API rate limits, max objects allowed) – Depends on the variable
- UI components – Depends on the variable
Create flag variable
You can create flag variables in the Feature Experimentation user interface (UI) or using the Feature Experimentation REST API.
Use the Feature Experimentation UI
-
Go to Flags and select a flag.
-
Click Variables and click + Add Variable.
-
Select the variable type.
-
Edit the Variable Key and optionally update the Description and Default Value.
Note
You cannot modify the Variable Key after you save the variable.
-
Create as many variables as you need for that flag by repeating steps 2 through 4.
-
Click Save.
Use the Optimizely Feature Experimentation REST API
You can use the Optimizely Feature Experimentation REST API Variable Definitions endpoints to manage your variables. See Create Variable Definition for more information.
Brainstorm variable ideas with Opal
You can brainstorm with Opal to automatically create variables.
-
Go to Flags and select a flag.
-
Click Variables and click Brainstorm.
-
Enter the hypothesis you want to test and click send (or press Enter). Opal returns suggestions for feature variables when running your experiment. See Design an effective hypothesis.
Note
The more info you provide, the better the responses.
-
(Optional) When reviewing Opal's variable suggestions, you can:
- Click Like brainstorm variable or Dislike brainstorm variable to provide feedback on the suggested variables.
- Click Add All to add all the suggestions as variables. Click Regenerate for Opal to create new variable ideas.
-
Select a variable suggestion to add the variable and review the AI-suggested fields.
Note
You cannot modify the Variable Key after you save it.
-
(Optional) Click Return to chat to brainstorm more variables and repeat steps 4 and 5.
-
Click Save to add the variables to your flag.
Implement variables
After you have created your variables, the next step is to create flag variations. Variations let you avoid hard-coding variables in your application and let you group and reuse variable values using flag rules.
Updated 9 months ago