Adding a Variable

Use Variables to parameterize your mobile app and easily run A/B tests on the parameters.
Variables can be defined in the VWO interface, and then used in your app. Once you define a variable, you can run an unlimited number of A/B tests on that variable, without any code changes or deploy.

Variables can be of type integer, float, string or boolean.
To create a variable, click on APPS section in Mobile App A/B.

1886

Use Create Variable button

2508

Enter the name of the variable, data type and a default value.
The default value is the original value for that variable. Default value gets used if there are no tests running.

Default value helps your write consistent code, without introducing checks for nil.
In the example above, we have defined speed integer variable with 5 default value.
The corresponding code for Java, Objective-C and Swift is also generated.
Now instead of using int speed = 5; use the below code.

int speed = VWO.getIntegerForKey("speed", 5);
val speed = VWO.getIntegerForKey("speed", 5)