Game Ops
Remote configs
To manual check if Remote Configs is ready (has been populated with values) you can call this:
- C++
- Javascript
- Lua
// C++
if(gameanalytics::cocos2d::GameAnalytics::isRemoteConfigsReady())
{
// the remote configs is ready, add your code here
}
// JS
if (ga.GameAnalytics.isRemoteConfigsReady()) {
// the remote configs is ready, add your code here
}
-- LUA
if ga.GameAnalytics.isRemoteConfigsReady() then
-- the remote configs is ready, add your code here
end
Remember the remote configs can be populated with an empty dictionary if the device is offline and there are no cached remote configs from a previous session.
To get values out of a populated Remote Configs use the following methods:
- C++
- Javascript
- Lua
// C++
// Without custom default value (using normal default value)
string value = gameanalytics::cocos2d::GameAnalytics::getRemoteConfigsValueAsString("key");
// With custom default value
string value = gameanalytics::cocos2d::GameAnalytics::getRemoteConfigsValueAsString("key", "myDefaultValue");
// JS
// Without custom default value (using normal default value)
var value = ga.GameAnalytics.getRemoteConfigsValueAsString("key");
// With custom default value
var value = ga.GameAnalytics.getRemoteConfigsValueAsString(
"key",
"myDefaultValue"
);
-- LUA
-- Without custom default value (using normal default value)
local value = ga.GameAnalytics.getRemoteConfigsValueAsString("key")
-- With custom default value
local value = ga.GameAnalytics.getRemoteConfigsValueAsString("key", "myDefaultValue")
If the specified key is not found in the Remote Configs it will return the default value either “normal”
or “custom”
default value.
A/B Testing
To get the value of A/B testing id or variant id use the following methods:
- C++
- Javascript
- Lua
// C++
// A/B testing id
string id = gameanalytics::cocos2d::GameAnalytics:: getABTestingId();
// A/B testing variant id
string variantId = gameanalytics::cocos2d::GameAnalytics:: getABTestingVariantId();
// JS
// A/B testing id
var id = ga.GameAnalytics.getABTestingId();
// A/B testing variant id
var variantId = ga.GameAnalytics.getABTestingVariantId();
-- LUA
-- A/B testing id
local id = ga.GameAnalytics.getABTestingId()
-- A/B testing variant id
local variantId = ga.GameAnalytics.getABTestingVariantId()
Remember the A/B testing ids are first available when the Remote Configs are ready.
Custom Dimensions
GameAnalytics support the use of up to 3 custom dimensions.
- Custom01
- Custom02
- Custom03
During the game it is possible to set the active value for each custom dimension dynamically. Once a dimension is set it will be persisted across sessions/game-start and automatically be added to all event categories. Remember you have to set the custom dimensions before initialzing the SDK (but after setting the available custom dimensions) to be able to add the dimensions to the first session start event.
Setting each custom dimension:
- C++
- Javascript
- Lua
gameanalytics::cocos2d::GameAnalytics::setCustomDimension01("ninja");
gameanalytics::cocos2d::GameAnalytics::setCustomDimension02("dolphin");
gameanalytics::cocos2d::GameAnalytics::setCustomDimension03("horde");
gameanalytics::cocos2d::GameAnalytics::setCustomDimension03(""); // reset dimension
ga.GameAnalytics.setCustomDimension01("ninja");
ga.GameAnalytics.setCustomDimension02("dolphin");
ga.GameAnalytics.setCustomDimension03("horde");
ga.GameAnalytics.setCustomDimension03(""); // reset dimension
ga.GameAnalytics:setCustomDimension01("ninja")
ga.GameAnalytics:setCustomDimension02("dolphin")
ga.GameAnalytics:setCustomDimension03("horde")
ga.GameAnalytics:setCustomDimension03("") -- reset dimension
|Field|Type|Description|Example|
|customDimension|string|One of the available dimension values set in the configuration phase. Will persist cross session. Set to empty to reset.|ninja
|
Read more about Custom Dimensions here