About Variables and Variable Sets
Variables allow you to dynamically define any element in your mobile application from within the Dynamic Yield admin. You paste a snippet of code in your mobile application and define the value in Dynamic Yield. For example, you might use a variable for a headline, image, or any other snippet of code you want to replace. This lets you make fast changes to your app without the need to redeploy it and submitting it for approval to the app store.
Variable Sets are groups of variables that also allow you to create variations and experiences to target different users with different values. For example, if you want to group a variable for a headline and one for an image, you could create a variable set that displays a particular headline/image combination for one audience, and a different combination for other audiences. You could also create a number of variations and utilize A/B testing to determine the best values to use for your variables.
Note: In most cases, retrieving the variable does not entail a roundtrip to the Dynamic Yield server as the values are already loaded within the init process are already cached within the SDK. The only case where a roundtrip would be made is when a user loads the app for the very first time and the experience using the required Variable is on the app’s first screen.
Creating a Variable
- Go to Settings › Variables and click Add New.
- Enter a name and labels (optional) to help organize your variables.
- Specify if the value is a string or a number.
- If the variable will be part of a variable set, check the Set possible values optional box and enter all of the potential values for the variable (one per line).
- The current value will be used if the variable is not part of a variable set as the value definition as long as there is no technical problem. In the event of a technical issue (e.g. internet connectivity), the fallback value will be used.
Note: The fallback value will be hardcoded in your app and cannot be dynamically changed later. This is by design as it should only be used in the event that a value cannot be retrieved from Dynamic Yield. The value can be null, but make sure that this does not negatively impact your app.
- Click Save and Get Code and paste the code in your app where you want to use the variable. For more details, see the Variable Sets API for iOS and Android.
Creating a Variable Set
- Create more than one variable as described above. If you want the variables to have multiple values, make sure you use the Set possible values optional checkbox and enter more than one potential value.
- Go to App Personalization › Variable Sets and click Add New.
- Specify a name and select the variables you want to include in the set. You can only include variables that are not part of another variable set.
- Click Next and click New Variation.
- Define the values to use for each variable in the variation for your default experience. Create as many variations as desired. The default experience is used if a user is not targeted by any other experience you create in this campaign to make sure that the variables always have some value.
- Configure the settings for the default experience such as allocation, primary metric, and advanced settings. When you are done, Save the experience.
- Click the plus icon
to create an additional targeted experience.
- Make sure all of the variable you used in the variable set are already pasted in your app and click Save and Publish when you’re ready to go.