- Optimizely X Mobile
- Optimizely X OTT
THIS ARTICLE WILL HELP YOU:
- Change the behavior of your app in real time
- Create experiments and roll out features without additional code deploys
- Register a new variable in Optimizely and add it to an experiments
Live variables allow you to change the behavior of your app from Optimizely in real time. By adding live variable getters in your app, you can create experiments or roll out features based on those variables, without the need for any more code deploys.
Variables are parameters in your app that you’d like the ability to control from Optimizely. We currently provide support for Boolean, double, integer, and string variables.
Variables can refer to any part of your app. For example:
A Boolean variable to indicate whether a feature is on or off
A double precision variable to indicate a multiplier in an algorithm
An integer variable to indicate the default items shown on a screen
A string variable to indicate the call to action text used in a button
Every variable must have a type (Boolean, Double, Integer, or String) and a default value to fall back on when no experiments are running. You can create as many variables as you wish in each project.
Once you’ve added variables to your app, change the values of variables from the Optimizely interface and run experiments on one or more variables at the same time.
Here's a few sample variables that configure the width, color, and text of a signup button on the fly:
When you use live variables, you'll need to make code changes in your app. This article will help you manage variables in the Optimizely web portal. We recommend looking at our developer documentation on iOS and Android to learn how to access live variables using the SDK.
1. Register a new variable in Optimizely
Tell Optimizely which parts of your app you want to parameterize and run experiments on.
Navigate to Variables > Create a Variable.
In the Create New Variable dialog, fill out the fields below.
The name of your variable: This variable name must be unique for your Optimizely project and can only contain alphanumeric characters, underscores and hyphens.
The type of variable: Boolean, Float, Integer, or String.
The default value for the variable: This is the value that the SDK returns by default if the variable is not included in any running experiments or the user isn’t bucketed into the experiment.
Here's an example for a variable called "SIGNUP_BUTTON_TEXT."
Click Save to make this variable available to experiments.
The dialog auto-populates a code snippet that you can use to access this variable in the SDK. You’ll need to do a code deploy before your app can connect remotely with Optimizely. Make sure the datafile contains the live variable data before you deploy.
2. Access variables from your app
3. Add a variable to an experiment
Once you've registered the variable and deployed a version of your app with getters, create an experiment and add a variable. You can add one or more variables.
Create an experiment in an SDK project.
After you set the experiment key, traffic allocation, and variation keys, add one or more variables. Click the () icon, or Create New Variable.
After you include the variable accessor in your app code and define the values of the variable you'll test, start the experiment. To test different values, use this form to change them or create a new experiment.
Use a variable for multiple experiments
By default, Optimizely experiments can overlap so the same user be in more than one experiment at the same time. Therefore, variables can only be used in one experiment at a time. Once a variable is included in an experiment, that variable won't be available in other experiments.
There is an exception to this behavior: if you're using mutually exclusive experiments. If you’ve created a group of experiments, you can reference the same variable for multiple experiments in that group. Each user will only see that variable in one experiment.
Use a variable to roll out a feature
You can also use variables to define features in your app and roll them out to your users.
To get started, define a Boolean variable in Optimizely indicating whether your feature is on or off. In the example below, we’ve created a variable to encompass a new signup flow, defaulting to False: