Integration
Downloading latest SDK
As a first point if you haven't already, please make sure you are integration with one of our latest SDKs to get started on using A/B testing.
Use the link below to download the and integrate our latest SDKs:
Define Experiment Variable
Next, select the area of your game that you want to A/B test.
Examples:
- Difficulty
- Price of an item
- Time interval between ads
Then define with your game the variable that you want to A/B test. The maximum allowed length of the variable is 256 characters.
Example:
- game_diff
- item_price
- ad_interval
This variable will be used when creating the experiment config key within GameAnalytics and when retrieving the config value using the SDK calls.
GameAnalytics will push to the player’s device, different values for this config depending on the key/value pairs that you define for the experiment.
For each variable, please ensure there is a default value that the game uses when no value is sent by GameAnalytics’ servers. Players who are allocated to the control group within an experiment will receive no value for the config key.
Add SDK Calls
Now you can add the calls from the SDK to get A/B Testing up and running. Use the below SDK calls to retrieve the values for your A/B testing configs.
The below code examples are for Unity, however you can find corresponding documentation for other SDKs within the Remote Configs section of the SDK integration guide.
Register For Events
Register to events for whenever A/B configs are updated with new values:
private static void MyOnRemoteConfigsUpdateFunction()
{
// add your code here
}
GameAnlytics.OnRemoteConfigsUpdatedEvent += MyOnRemoteConfigsUpdateFunction;
Manual Check
To manually check if A/B configs are ready (have been populated with values) you can call this:
Call: IsRemoteConfigsReady();
Description: Checks if Remote Configs are ready and have been loaded with values
Returns(bool): True if Remote Configs is ready (loaded with values) else false
Example:
if(GameAnalytics.IsRemoteConfigsReady ()) {
//Remote Configs ready add your code here
}
Get Specific A/B Config Values
To get values out of a populated A/B configs use the following methods:
Call: GetRemoteConfigsValueAsString (string key)
Description: Gets A/B Config value using the specified key.
Returns(string): A/B Config value at the specified key. This will always return null if it is called before Remote Configs is ready
Example:
string value = GameAnalytics.GetRemoteConfigsValueAsString ("ab_key")
Call: GetRemoteConfigsValueAsString (string key, string defaultValue)
Description: Gets A/B Config value using specified key.
Returns(string): A/B Config value at the specified key. If there is no value at the specified key the call will return the defaultValue. If it is called before Remote Configs is ready it will also return the defaultValue.
Example:
string value = GameAnalytics.GetRemoteConfigsValueAsString ("ab_key", "myDefaultValue");
If the specified key is not found in the A/B configs it will return the default value either “normal” or “custom” default value.
Get All A/B Config Values
Call: GetConfigurationsContentAsString() Description: Gets all available remote configs fetched from the server (including A/B configs values if any) Returns(string): json with all available configurations
Example:
string json = GameAnalytics.GetConfigurationsContentAsString ();
You are now ready to create and run A/B tests within GameAnalytics. For further information, please check out our guide here