- Optimizely X Full Stack, 1.x SDKs only
- Optimizely Classic Mobile
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.
Live variables are available on the Full Stack 1.x SDKs -- and are being deprecated. With Optimizely's 2.x SDKs, you'll have access to feature configuration (and feature variables), as well as environments and SDK keys. Please upgrade to the new 2.x SDKs and pause and archive projects that use live variables to gain access.
If you're using the 1.x SDKs for Android, iOS, or OTT, learn more about upgrading to version 2.x.
1. Register a new variable in Optimizely
Tell Optimizely which parts of your app you want to parameterize and run experiments on. Here's how, with steps listed below:
Navigate to Variables > Create New 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, Double, 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.
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
After 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 (scroll down for step-by-step instructions).
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 an exclusion group of experiments, you can reference the same variable for multiple experiments in that exclusion group. Each user will only see that variable in one experiment.
Use a variable to roll out a feature
You can 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 True (on) or False (off). In this example, we created a variable to encompass a new sign-up flow, defaulting to False:
After you deploy the variable accessor in your app, you can create an experiment with a single variation to roll out the feature gradually to your users:
You can use experiment traffic allocation or audience targeting to limit which users see the feature and expand the traffic allocation or introduce more audiences over time.
In this example, we created an experiment with a single variation. If you prefer, you can keep a control variation with the feature turned off to see the statistical impact of your new feature on metrics you’ve defined.
To remove a variable from the Optimizely web portal, click the Actions () icon for the variable and select Archive.
Archiving doesn't delete the variable, but it prevents the variable from appearing as an option to include in your experiments. Any existing experiments that reference the variable will continue to run, and you can unarchive variables at any time.