Game Ops
Remote Configs
GameAnalytics offers the option to setup remote configs in your dashboard that can be changed on the whim without needing to release a new version of the game. The remote configs are a custom set of key-pair values.
- (void) onRemoteConfigsUpdated
{
// add your code here
}
[GameAnalytics setRemoteConfigsDelegate:self];
You can use this method to manually check if the Remote Configs are ready (if they have been populated with the values from the dashboard):
if([GameAnalytics isRemoteConfigsReady])
{
// the remote configs is ready, add your code here
}
To get the values out of a populated Remote Config the following methods are employed:
// Without custom default value (using normal default value)
NSString *value = [GameAnalytics getRemoteConfigsValueAsString:@"key"];
// With custom default value
NSString *valueWithCustomDefaultValue = [GameAnalytics getRemoteConfigsValueAsString:@"key" defaultValue:@"myDefaultValue"];
If the specified key is not found in the Remote Configs it will return a default value which can be one of the following: “normal”
or “custom”
.
A/B Testing
To get the value of A/B testing id or variant id use the following methods:
// A/B testing id
NSString *abTestingId = [GameAnalytics getABTestingId];
// A/B testing variant id
NSString *abTestingVariantId = [GameAnalytics getABTestingVariantId];
Remember the A/B testing ids are first available when the Remote Configs are ready.
Custom Dimensions
GameAnalytics supports 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:
- swift
- Objective-C
// Swift
GameAnalytics.setCustomDimension01("ninja")
GameAnalytics.setCustomDimension02("dolphin")
GameAnalytics.setCustomDimension03("horde")
// Objective-C
[GameAnalytics setCustomDimension01:@"ninja"];
[GameAnalytics setCustomDimension02:@"dolphin"];
[GameAnalytics setCustomDimension03:@"horde"];
|Field|Type|Description|Example| |customDimension|string|One of the available dimension values set in the configuration phase. Will persist cross session. Set to nil to reset.|ninja|
To reset a custom dimension during a session simply set the dimension name to nil. For instance, to reset the custom dimension01
the following call needs to be written:
- swift
- Objective-C
// Swift
GameAnalytics.setCustomDimension01(nil)
// Objective-C
[GameAnalytics setCustomDimension01:nil];
Read more about custom dimensions here.
Custom Event Fields
During the game it is possible to set global custom event fields which you can change at any time. Custom event fields is basically a set of key-value pairs you can add to all your events.
It is important to know that the custom event fields will not be visible in the GameAnalytics tool as it is only accessible through raw export.
There is a limit of using 50 custom event fields per event, keys can max consist of 64 characters and values (when strings) can max consist of 256 characters.
Custom event fields can only be used together with raw event export and which they will not visible in the tool. It is also possible to overwrite the global custom event fields by using the optional custom event fields parameter for when sending individual events, please refer to the events documentation page for usage. If you want to merge the specified custom fields from the event method parameter with the global custom event fields set the optional mergeFields
event method parameter to true.
Setting global custom event fields:
NSMutableDictionary *fields = [[NSMutableDictionary alloc] init];
fields[@"test"] = @1000;
fields[@"test_2"] = @"global_hello_world";
[GameAnalytics setGlobalCustomEventFields:fields];
Field | Type | Description | Example |
---|---|---|---|
customFields | dictionary | A set of key-value pairs. Values can be strings or numbers | { "test": 1000 "tests": "hello_world" } |
Error Reporting
By default the SDK will automatically send over error events for uncaught exceptions. This can be disabled by calling this before the SDK has been initialized:
- Swift
- Objective-C
// Swift
GameAnalytics.setEnabledErrorReporting(false)
// Objective-C
[GameAnalytics setEnabledErrorReporting:NO];
If you are using other crash/error reporting services (like for example Crashlytics) together, GameAnalytics’ automatic error reporting can in some cases give problems, however the SDK makes sure to call any error handlers set prior to GameAnalytics error handler.