Defold SDK

The Defold SDK include platform support for iOSAndroidHTML5,
Windows and Mac.

Requirements

  • Defold: 1.2.108+
  • iOS: iOS 7+
  • Android: Android API Level 14

Build size

The SDK contain support for all platforms and CPU architectures. Note that the download size differ from the actual build size. The additional size of adding GameAnalytics depend on the platform, but it is often very low. For Android it could be as low as 50kb depending on what standard libraries are already included in the game/app.

SETUP

Installation

Github Repository

To install the SDK add this link to the project dependencies (this will always get the latest version):

https://github.com/GameAnalytics/GA-SDK-DEFOLD/archive/master.zip

Or to get a specific version use a link like this (this example will get version 1.0.0):

https://github.com/GameAnalytics/GA-SDK-DEFOLD/archive/1.0.0.zip

Configuring game.project

The game.project file must configured before using the SDK. The available configuration options are listed here.

  • Game Key + Secret Key
  • Build (optional)
  • Custom dimensions (optional)
  • Resource Currency and Item Types (optional)
  • Use custom user id (optional)
  • Use manual session handling (optional)
  • Logging

Remember to create new section for the SDK in the game.project file:

[gameanalytics]

Game Key + Secret Key

For each platform you need to configure a set of game keys.

ℹ️
game key is a unique identifier for your game.
secret key is used to protect event data from being tampered with as it travels to the GameAnalytics servers.

Notice there is a specific entry for each platform:

[gameanalytics]
game_key_ios = IOS_GAME_KEY
secret_key_ios = IOS_SECRET_KEY
game_key_android = ANDROID_GAME_KEY
secret_key_android = ANDROID_SECRET_KEY
game_key_html5 = HTML5_GAME_KEY
secret_key_html5 = HTML5_SECRET_KEY
game_key_osx = OSX_GAME_KEY
secret_key_osx = OSX_SECRET_KEY

Build

Build is used to specify the current version of your game. Recommended to use a 3 digit version like [major].[minor].[patch]. Notice there is a specific entry for each platform:

[gameanalytics]
build_ios = 0.1
build_android = 0.1
build_html5 = 0.1
build_osx = 0.1

Custom Dimensions

During gameplay it is possible to set values for 3 different custom dimensions. For each custom dimension it is needed specify a whitelist. You cannot set a custom dimensionvalue unless it is specified here first.

ℹ️
For more information about custom dimensions go here.

The dimensions are comma-seperated like shown in the example (remember no space in between each entry):

[gameanalytics]
custom_dimensions_01 = ninja,samurai
custom_dimensions_02 = whale,dolphin
custom_dimensions_03 = horde,alliance

Resource Currency and Item Types

When submitting resource events you specify a resource currency and resource item type. It is needed to specify a whitelist for each of these. You cannot submit a resource event using other values than specified here.

ℹ️
Each resource currency string should only contain [A-Za-z] characters.

The currencies and item types are comma-seperated like shown in the example (remember no space in between each entry):

[gameanalytics]
resource_currencies = gold,gems
resource_item_types = boost,lives

Use custom id

TThe SDK will automatically generate a user id and this is perfectly fine for almost all cases.

Sometimes it is useful to supply this user_id manually – for example if you download raw data for processing and need to match your internal user id (could be a database index on your user table) to the data collected through GameAnalytics.

⚠️
Do not use a custom userId unless you have a specific need for using it.

ℹ️
Note that if you introduce this into a game that is already deployed (using the automatic id) it will start counting existing users as new users and your metrics will be affected. Use this from the start of the game lifetime.

ℹ️
When using custom id you need to remember GameAnalytics will first be fully initialized when you have set the custom id. No events can be sent before GameAnalytics is fully initialized.

To enable custom user id, add this to the game.project file:

[gameanalytics]
use_custom_id = 1

To set custom user id in the game call this from your script:

gameanalytics.configureUserId( "my_custom_id" )

Use manual session handling

To enable manual session handling, add this to the game.project file:

[gameanalytics]
use_manual_session_handling = 1

To manual enable or disable session handling later on call this:

gameanalytics.setEnabledManualSessionHandling(true)

Read more about sessions here including manual session handling.

Logging

The info log will output basic information about what is happening when your game is built for native. The verbose log will output the event JSON data that is being sent to the GameAnalytics servers when your game is built for native.

To enable them add this to the game.project file:

[gameanalytics]
enable_info_log = 1
enable_verbose_log = 1

Setup for HTML5

For HTML5 builds you need to manually add this line to the resulting .html file:

It is also possible to create a html template file where it is already added to.

INITIALIZE SDK

Using the SDK

Now we should be ready for adding code to activate the SDK!
There are 3 phases the SDK will go through.

  1. configuration
  2. initialization
  3. adding events or changing dimensions

Configuration calls configure settings for the SDK and some will not be able to be altered after initialize has been called. Read more about configuration here.

Initialize call will start the SDK and activate the first session. The SDK is automatically intialized when the Defold GameAnalytics extension is loaded. It uses the keys set in the game.project file.

Once the project dependency has been added the SDK should be ready use from any lua script in the project.

ADDING EVENTS

About

GameAnalytics feature the following event types.

Event Description
Business In-App Purchases supporting receipt validation on GA servers.
Resource Managing the flow of virtual currencies – like gems or lives.
Progression Level attempts with Start, Fail & Complete event.
Error Submit exception stack traces or custom error messages.
Design Submit custom event id’s. Useful for tracking metrics specifically needed for your game.

⚠️
Event id’s are strings separated by colons defining an event hierarchy – like “kill:robot:large”. It is important to not generate an excessive amount of unique nodes possible in the event hierarchy tree.

A bad implementation example.
[level_name]:[weapon_used]:[damage_done]

level_name could be 100 values, weapon_used could be 300 values and damage_done could be 1-5000 perhaps. This will generate an event hierarchy with:

100 * 300 * 5000 = 150M possible nodes.

This is far too many. Also the damage should be put as a value and not in the event string. The processing will perhaps be blocked for a game doing this and cause other problems when browsing our tool.

The maximum amount of unique nodes generated should be around 10k.

ℹ️
Please read our event guide here. You will get the most benefit of GameAnalytics when understanding what and how to track.

Business

Business events are used to track in-app purchases with real money.

ℹ️
Mobile games can be hacked and distributed illegally.
Hacking an app will often involve faking/simulating all purchase requests. This will result in several Business events being sent to GameAnalytics for transactions that never occurred.

GameAnalytics provide the option of receipt validation for each purchase sent to GA servers. This process can ensure that revenue metrics reflect the actual spending in your game.

⚠️
Some configuration is needed before receipt validation will be active.
Read information about validation and requirements for different platforms here.

Receipt validation in Corona is supported for the following stores.

  • App Store (iOS)
  • Google Play Store (Android)

Go to gameanalytics.addBusinessEvent() to see how to send a business event.

Resource

Resource events are used to register the flow of your in-game economy (virtual currencies) – the Sink (subtract) and the Source (add) for each virtual currency.

ℹ️
Before calling the resource event it is needed to specify what discrete values can be used for currencies and item types in the Configuration phase.

Source (add) Gem currency from an in-app purchase.

gameanalytics.addResourceEvent {
    flowType = "Source",
    currency = "Gems",
    amount = 400,
    itemType = "IAP",
    itemId = "Coins400"
}

Sink (subtract) Gem currency to buy an item.

gameanalytics.addResourceEvent {
    flowType = "Sink",
    currency = "Gems",
    amount = 400,
    itemType = "Weapons",
    itemId = "SwordOfFire"
}

Sink (subtract) Gem currency to Source (buy) some amount of another virtual currency (BeamBooster).

gameanalytics.addResourceEvent {
    flowType = "Sink",
    currency = "Gems",
    amount = 100,
    itemType = "Boosters",
    itemId = "BeamBooster5Pack"
}
gameanalytics.addResourceEvent {
    flowType = "Source",
    currency = "BeamBooster",
    amount = 5,
    itemType = "Gems",
    itemId = "BeamBooster5Pack"
}

Sink (subtract) 3 BeamBooster currency that were used during a level.

gameanalytics.addResourceEvent {
    flowType = "Sink",
    currency = "BeamBooster",
    amount = 3,
    itemType = "Gameplay",
    itemId = "BeamBooster5Pack"
}

Go to gameanalytics.addResourceEvent() for more information on how to send a resource event.

⚠️
Be careful to not call the resource event too often !

In a game where the user collect coins fairly fast you should not call a Source event on each pickup. Instead you should count the coins and send a single Source event when the user either complete or fail the level.

ℹ️
For more information on the resource event go here .

Progression

Progression events are used to track attempts at completing some part of a game (level, area). A defined area follow a 3 tier hierarchy structure (could be world:stage:level) to indicate what part of the game the player is trying to complete.

When a player is starting a progression attempt a start event should be added. When the player then finishes the attempt a fail or complete event should be added along with a score if needed.

Add a progression start event.

gameanalytics.addProgressionEvent {
    progressionStatus = "Start",
    progression01 = "world01",
    progression02 = "stage01",
    progression03 = "level01"
}

It is not required to use all 3 if your game does not have them.

  • progression01
  • progression01 and progression02
  • progression01 and progression02 and progression03

Go to gameanalytics.addProgressionEvent() for more information on how to send a progression event.

ℹ️
For more information on the progression event go here.

Error

Used to track custom error events in the game. You can group the events by severity level and attach a message.

To add a custom error event call the following function:

gameanalytics.addErrorEvent {
    severity = "Debug",
    message = "Something went bad in some of the smelly code!"
}

Go to gameanalytics.addErrorEvent() for more information on how to send an error event.

ℹ️
For more information on the error event go here.

Design

Every game is special. Therefore some needed events might not be covered by our other event types. The design event is available for you to add your own event-id hierarchy.

ℹ️
Please note that custom dimensions and progression filters will not be added on design and error events. Therefore you cannot (at the moment) filter by these when viewing design or error metrics.

To add a design event call the following method.

gameanalytics.addDesignEvent {
    eventId = "Kill:Sword:Robot"
}

It is also possible to add a float value to the event.
This will (in addition to count) make the mean and sum aggregation available in the tool.

gameanalytics.addDesignEvent {
    eventId = "BossFights:FireLord:KillTimeUsed",
    value = 234
}

Go to gameanalytics.addDesignEvent() for more information on how to send a resource event.

⚠️
It is important to not generate an excessive amount of unique nodes possible in the event hierarchy tree.

A bad implementation example.
[level_name]:[weapon_used]:[damage_done]

level_name could be 100 values, weapon_used could be 300 values and damage_done could be 1-5000 perhaps. This will generate an event hierarchy with:

100 * 300 * 5000 = 1.5M possible nodes.

This is far too many. Also the damage should be put as a value and not in the event string. The processing will perhaps be blocked for a game doing this and cause other problems when browsing our tool.

The maximum amount of unique nodes generated should be around 10k.

ℹ️
Please read our event guide here. You will get the most benefit of GameAnalytics when understanding what and how to track.

CUSTOM DIMENSIONS

Using Custom Dimensions

GameAnalytics support the use of 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 these event categories.

  • Business
  • Resource
  • Progression

Setting each custom dimension. To reset a set custom dimension simply just set it to empty string

gameanalytics.setCustomDimension01("ninja")
gameanalytics.setCustomDimension02("dolphin")
gameanalytics.setCustomDimension03("horde")

-- reset custom dimension 3
gameanalytics.setCustomDimension03("") 

Go to gameanalytics.setCustomDimension01()gameanalytics.setCustomDimension02() or gameanalytics.setCustomDimension03() for more information on how to set a custom dimension.

ℹ️
Read more about custom dimensions here.

DEMOGRAPHICS

User Information

During the game it is possible to set information about your users that will then be annotated to all other events.

  • gender
  • Facebook ID
  • birthyear (age)

ℹ️
These user values will persist cross session/game-launch. Set them to empty string to reset.

Set gender.

gameanalytics.setGender("female")

Set birthyear.

gameanalytics.setBirthYear(1980)

Set Facebook ID.

gameanalytics.setFacebookId("123456789012345")

Go to gameanalytics.setGender()gameanalytics.setBirthYear() or gameanalytics.setFacebookId() for more information on how to use these functions.

DEBUG & VERIFY

Debugging

The SDK is designed to be as silent as possible and use very few resources. You will therefore not get much information by default in your development console.

We have 2 different debug log types that can be enabled / disabled (at any time or during configuration).

  • info log
  • verbose log

Info log

Short messages will be output when enabled explaining when some action is being performed by the SDK. Sometimes cropping text / values to make it more readable.

Enable info log when implementing the SDK – remember to turn it off in production!

gameanalytics.setEnabledInfoLog(true)
Info/GameAnalytics: Add DESIGN event: {eventId:someEvent, value:0}
 Info/GameAnalytics: Add DESIGN event: {eventId:someOtherEvent, value:100}
 Info/GameAnalytics: Add ERROR event: {severity:info, message:This is some in}

Verbose Log

Console output when each event is added (all fields) in JSON string format. This is the data being submitted to the GA servers for each event.

Enable verbose log when troubleshooting events.

gameanalytics.setEnabledVerboseLog(true)

This can result in a lot of text. When troubleshooting/debugging events it is therefore recommended to enable/disable when performing the action that need inspection.

Troubleshooting example.

 -- enable verbose log
 gameanalytics.setEnabledVerboseLog(true)
 -- add event you need to troubleshoot / inspect
gameanalytics.addDesignEvent {
    eventId = "Some:Event",
    value = 100
}
 -- disable verbose log 
 gameanalytics.setEnabledVerboseLog(false)

Go to gameanalytics.setEnabledInfoLog() or gameanalytics.setEnabledVerboseLog() for more information on how to use these functions.

Verify Implementation

Enable the Info Log to verify that events are being sent from your game project without any issues being reported.

Events submitted should register after a minor delay in our realtime dashboard in the GameAnalytics tool.

ℹ️ Read more about the realtime dashboard and our data processing.

HOW DOES IT WORK?

Session Handling

By default the SDK will handle session start/end automatically, but it is also possible to manually control this yourself.

⚠️
Be aware that the initialization will always automatically start the first session even with manual session handling. If you are using ads in your game there is a big possibility that the onPause() and onStop() events will be triggered when the ads are showing which will interfere with the session length for information on how to fix this to look here

Automatic session handling

The automatic session handling will track the focused time the user is spending in your game – from game launch to the user leaving the game.

session start
On Android a new session will start once the game is launched or when the app is resumingif there is no current session.

session end
A session will end once the game is going to homescreen (or is not visible anymore).

It will end the session at once if the application received the onStop event from the game activity. It can also end the session if onPause event was received and 90 seconds have passed (sometimes only the onPause will trigger even though the user left the app).

Manual session handling

The automatic session handling only works if the game is contained in one activity.

It will then handle session end and start based on the events on that single activity. This behavior is common (having one activity) but some games define multiple activities and this automatic session handling will not work in an optimal way.

If your game does have multiple activities (or you just want to be in control when to start and end sessions) you can enable/disable manual session handling by calling this at any given time:

gameanalytics.setEnabledManualSessionHandling(true)

You will then need to call endSession and startSession at the appropriate times.

⚠️
With manual session handling it is recommended to also call endSession when the game activity event onStop is fired. This will ensure a correct session close when users click the home or on/off button.

endSession()

gameanalytics.endSession()

This will end a session if:

  • manual session handling is enabled
  • a session is active
  • SDK is initialized (initialize will start a session automatically)

startSession()

gameanalytics.startSession()

This will start a new session if:

  • manual session handling is enabled
  • SDK is initialized (initialize will start a session automatically)

If a current session is active then it will end the current session and start a new one.

Handling ads and preserve correct session length

Ads will most likely trigger onPause() and onStop() which will interfere with the session length of the game. To prevent this you need to use manual session handling at least when you are about to show ads.

If you are already using manual session handling from the beginning of your game then you don’t need to worry about this.

Behind the scenes

This is what happens when the session is starting or ending.

Session start

  1. Generate new session.
  2. Add a session start event (a “user” event).
  3. Start the periodic activation of submitting queued events.
  4. Next event submit will fix potential missing session_end from earlier sessions.

Session end

  1. Stop the periodic activation of submitting queued events.
  2. Add a session_end event.
  3. Submit queued events.

SETUP

Event Queue

Whenever an event is added (and validated) it will be added to a local database queue.

Interval

Every 8 seconds the SDK will start a task for submitting queued events since last submit. This processing is done in a separate low-priority thread that will have minimum impact on performance. The payload is gzipped and will therefore only consume a small amount of bandwidth.

Offline

When a device is offline the events are still added to the queue. When the device is online it will submit.

Thread Handling

For the Android platform almost every piece of this code is run using a dedicated low-priority serial thread queue to avoid UI lag or sudden performance spikes.

The queue will execute each task sequentially. If the SDK add several tasks to the queue then each will be executed in turn. A task could be adding an event or submitting all queued events.

Consider this example with 3 calls.

-- Configure build version
gameanalytics.configureBuild("alpha 0.1.0")
-- Initialize
gameanalytics.initialize("12341234123412341234123412341234", "1234123412341234123412341234123412341234");
-- Add Design event
gameanalytics.addDesignEvent("Some:Event")

The configureBuild is required to be called before initialize is completely finished. The design event call is required after initialise is finished. The queuing will make sure that each task is completely finished before proceeding to the next one.

There is more!

There is much more to GameAnalytics and we suggest that you read our general documentation.

Please create a support ticket if you have any feedback like..

  • bugs
  • confusing features or UI
  • great ideas!

We hope you enjoy our service!

FUNCTIONS

Available Functions

Here is a list of available function in the GameAnalytics extension:

gameanalytics.configureUserId()
gameanalytics.addBusinessEvent()
gameanalytics.addResourceEvent()
gameanalytics.addProgressionEvent()
gameanalytics.addDesignEvent()
gameanalytics.addErrorEvent()
gameanalytics.setEnabledInfoLog()
gameanalytics.setEnabledVerboseLog()
gameanalytics.setEnabledManualSessionHandling()
gameanalytics.setCustomDimension01()
gameanalytics.setCustomDimension02()
gameanalytics.setCustomDimension03()
gameanalytics.setFacebookId()
gameanalytics.setGender()
gameanalytics.setBirthYear()
gameanalytics.startSession()
gameanalytics.endSession()

configureUserId()

Overview

Set a custom unique user_id identifying the user. Can only be used when custom user id has been enabled during configuration. Initializes SDK once it is called.

Syntax

gameanalytics.configureUserId( id )

id (required)

_String._ The custom id. Must be non-empty.

Examples

gameanalytics.configureUserId( "my_custom_id" )

[Back to index]


addBusinessEvent()

Overview

Add new business event.

Syntax

gameanalytics.addBusinessEvent( options )

options (required)

_Table._ Required parameters:

  • currency (String): currency code in ISO 4217 format, e.g USD
  • itemType (Number): amount in cents
  • itemId (String): specific item bought

Optional parameters (for both Android iOS):

  • cartType (String): the game location of the purchase
  • amount (String): the type / category of the item
  • receipt (String):
    • Android:
      • Android IAP receipt, must be a string not encoded to base64 as the Android library will handle the encoding
      • signature also required when used, read more here
    • iOS:
      • App Store receipt, must be base64 string, read more here

Syntax

{
    "orderId": "",
    "packageName": "",
    "productId": "",
    "purchaseTime": 1484080095335,
    "purchaseState": 0,
    "purchaseToken": ""
}

Optional parameters (for Android):

  • signature (String): Android IAP signature, must be base64 string, required when using receipt read more here

Optional parameters (for iOS):

  • autoFetchReceipt (Boolean): if true auto-fetch receipt

Examples

-- Non-validated business event (all platforms)
gameanalytics.addBusinessEvent {
    currency = "USD",
    amount = 100,
    itemType = "boost",
    itemId = "megaBoost",
    cartType = "shop"
}

local info = sys.get_sys_info()

-- Validated business event (for Android)
if(info.system_name == "Android") then
    gameanalytics.addBusinessEvent {
        currency = "USD",
        amount = 100,
        itemType = "boost",
        itemId = "megaBoost",
        cartType = "shop",
        receipt = "",
        signature = ""
   }
end

-- Validated business event (for iOS)
if(info.system_name == "iPhone OS") then
    gameanalytics.addBusinessEvent {
        currency = "USD",
        amount = 100,
        itemType = "boost",
        itemId = "megaBoost",
        cartType = "shop",
        receipt = ""
    }

    -- Validated business event using auto-fetch receipt (for iOS)
    gameanalytics.addBusinessEvent {
        currency = "USD",
        amount = 100,
        itemType = "boost",
        itemId = "megaBoost",
        cartType = "shop",
        autoFetchReceipt = true
    }
end

[Back to index]


addResourceEvent()

Overview

Add new resource event.

Resources events are used to track your in-game economy. From setting up the event you will be able to see three types of events in the tool. Flow, the total balance from currency spent and rewarded. Sink is all currency spent on items, and lastly source, being all currency rewarded in game.

Syntax

gameanalytics.addResourceEvent( options )

options (required)

_Table._ Required parameters:

  • flowType (String): Add (‘Source’) or substract (‘Sink’) resource, value must be ‘Source’ or ‘Sink’
  • currency (String): one of the available resource currencies
  • amount (Number): amount sourced or sinked, must be greater than zero
  • itemType (String): one of the available item types
  • amount (String): item id, max length=32

Examples

gameanalytics.addResourceEvent {
    flowType = "Sink",
    currency = "gold",
    amount = 10,
    itemType = "lives",
    itemId = "5lives"
}

[Back to index]


addProgressionEvent()

Overview

Add new progression event.

Syntax

gameanalytics.addProgressionEvent( options )

options (required)

_Table._ Required parameters:

  • progressionStatus (String): status of added progression, value must be ‘Start’, ‘Complete’ or ‘Fail’
  • progression01 (String): 1st progression e.g. world01

Optional parameters:

  • progression02 (String): 2nd progression e.g. level01
  • progression03 (String): 3rd progression e.g. phase01
  • score (Number): the player’s score

Examples

gameanalytics.addProgressionEvent {
    progressionStatus = "Start",
    progression01 = "world01"
}
gameanalytics.addProgressionEvent {
    progressionStatus = "Complete",
    progression01 = "world01",
    score = 100
}
gameanalytics.addProgressionEvent {
    progressionStatus = "Fail",
    progression01 = "world01",
    progression02 = "level01"
}
gameanalytics.addProgressionEvent {
    progressionStatus = "Complete",
    progression01 = "world01",
    progression02 = "level01",
    score = 100
}
gameanalytics.addProgressionEvent {
    progressionStatus = "Start",
    progression01 = "world01",
    progression02 = "level01",
    progression03 = "phase01"
}
gameanalytics.addProgressionEvent {
    progressionStatus = "Complete",
    progression01 = "world01",
    progression02 = "level01",
    progression03 = "phase01",
    score = 100
}

[Back to index]


addDesignEvent()

Overview

Add new design event.

Used to track any type of design event that you want to measure i.e. GUI elements or tutorial steps. Custom dimensions are not supported for design events.

Syntax

gameanalytics.addDesignEvent( options )

options (required)

_Table._ Required parameters:

  • eventId (String): The event string can have 1 to 5 parts. The parts are separated by ‘:’ with a max length of 64 each. e.g. “world1:kill:robot:laser”

Optional parameters:

  • value (Number): number value of event

Examples

gameanalytics.addDesignEvent {
    eventId = "design:event"
}
gameanalytics.addDesignEvent {
    eventId = "design:event",
    value = 10
}

[Back to index]


addErrorEvent()

Overview

Add new error event.

Used to track custom error events in the game. You can group the events by severity level and attach a message.

Syntax

gameanalytics.addErrorEvent( options )

options (required)

_Table._ Required parameters:

  • severity (String): severity of error, value must be ‘Critical’, ‘Debug’, ‘Error’, ‘Info’ or ‘Warning’

Optional parameters:

  • message (String): error message

Examples

gameanalytics.addErrorEvent {
    severity = "Critical",
    message = "This is a message!!"
}

[Back to index]


setEnabledInfoLog()

Overview

Enable info logging to console.

Syntax

gameanalytics.setEnabledInfoLog( flag )

flag (required)

_Boolean._ Enable or disable info log mode.

Examples

gameanalytics.setEnabledInfoLog( true )

[Back to index]


setEnabledVerboseLog()

Overview

Enable verbose info logging of analytics. Will output event JSON data to console.

Syntax

gameanalytics.setEnabledVerboseLog( flag )

flag (required)

_Boolean._ Enable or disable verbose info log mode

Examples

gameanalytics.setEnabledInfoLog( true )

[Back to index]


setEnabledManualSessionHandling()

Overview

Enable manual session handling.

This will disable the automatic session stop/start when the app goes to background/foreground and it is then needed to call gameanalytics.endSession() & gameanalytics.startSession() manually. Remember to call gameanalytics.endSession() when the app is going to background. The first session will always be started automatically when SDK is initialized.

Syntax

gameanalytics.setEnabledManualSessionHandling( flag )

flag (required)

_Boolean._ Enable or disable manual session handling.

Examples

gameanalytics.setEnabledInfoLog( true )

[Back to index]


setCustomDimension01()

Overview

Set 1st custom dimension.

Syntax

gameanalytics.setCustomDimension01( dimension )

dimension (required)

_String._ One of the available dimension values set in game.project. Will persist cross session. Set to empty to reset.

Examples

gameanalytics.setCustomDimension01( "ninja" )

[Back to index]


setCustomDimension02()

Overview

Set 2nd custom dimension.

Syntax

gameanalytics.setCustomDimension02( dimension )

dimension (required)

_String._ One of the available dimension values set in game.project. Will persist cross session. Set to empty to reset.

Examples

gameanalytics.setCustomDimension02( "dolphin" )

[Back to index]


setCustomDimension03()

Overview

Set 3rd custom dimension.

Syntax

gameanalytics.setCustomDimension03( dimension )

dimension (required)

_String._ One of the available dimension values set in game.project. Will persist cross session. Set to empty to reset.

Examples

gameanalytics.setCustomDimension03( "horde" )

[Back to index]


setFacebookId()

Overview

Set user facebook id.

Syntax

gameanalytics.setFacebookId( facebookId )

facebookId (required)

_String._ Facebook id of user (Persists cross session).

Examples

gameanalytics.setFacebookId( "my_facebook_id" )

[Back to index]


gameanalytics.setGender()

Overview

Set user gender.

Syntax

gameanalytics.setGender( gender )

gender (required)

_String._ Gender of user (Persists cross session). Must be one of ‘Male’ or ‘Female’

Examples

gameanalytics.setGender( "Male" )

[Back to index]


setBirthYear()

Overview

Set user birth year.

Syntax

gameanalytics.setBirthYear( birthYear )

birthYear (required)

_Number._ Birth year of user (Persists cross session)

Examples

gameanalytics.setBirthYear( 1984 )

[Back to index]


startSession()

Overview

Start a new session.

  • if sdk is initialized
  • if manual session handling is enabled

If a current session is currently active then it will end this session and start a new.

Syntax

gameanalytics.startSession()

Examples

gameanalytics.startSession()

[Back to index]


endSession()

Overview

End an active session.

  • if sdk is initialized
  • if manual session handling is enabled
  • a session is active

If a current session is currently active then it will end this session and start a new.

Syntax

gameanalytics.endSession()

Examples

gameanalytics.endSession()

[Back to index]