Skip to main content

Setup

Download & Installation

Download SDK files from Github here.

Construct 2

Unzip the downloaded .zip and drag and drop the gameanalytics.c2addon file into your Construct 2 project and accept the installation of the plugin.

Construct 3

Unzip the downloaded .zip and open your Construct 3 project, click Menu -> View -> Addon manager -> Install new addon…, select the gameanalytics.c3addon file and accept the installation of the plugin.

info

Remember you need to restart Construct before you can start using the GameAnalytics plugin.

Cordova export

When exporting for Cordova remember to call cordova plugin add cordova-plugin-gameanalytics and cordova plugin add cordova-plugin-device in the exported Cordova project (since v2.0.2 this is not needed to do anymore for Construct 3). Remember to select Cordova project when exporting and not Xcode project as it has only been tested with the “Cordova project” option.

tip

Remember the GameAnalytics Constructor plugin doesn’t work in “Worker Mode”.

Initialize Sdk

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

  • configuration
  • initialization
  • 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.

Initialize call will start the SDK and activate the first session.

The configuration and initialization steps should be called when the application starts.

Once step 1 & 2 is done you can add events at different parts of the game code where some relevant action is happening.

Remember to add the GameAnalytics object to the project before you can use the SDK:

  • Right-click on Object types
  • Click on Insert New Object
  • Choose GameAnalytics (under Analytics category)
  • Click on Insert

Configuration

The configuration phase happens before initialization is called. The available configuration options are listed here.

  • build
  • custom userId
  • available (allowed) custom dimensions
  • available (allowed) resource currencies
  • available (allowed) resource item types

Build

Build is used to specify the current version of your game. Specify it using a string. Recommended to use a 3 digit version like [major].[minor].[patch]

Set the build version by selecting the GameAnalytics object editing the value under the Properties section, then it will automatically be set when initializing the SDK.

Auto detect app version to use for build field

There is an option to auto detect app version to use for build field (only for corodova export). Just enable it in the Properties section.

Custom userId

The 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.

tip

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

info

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.

Set the custom user id by selecting the GameAnalytics object editing the value under the Properties section, then it will automatically be set when initializing the SDK.

Specifying allowed values

For certain types it is required to define a whitelist containing possible unique values during the configuration phase. When the SDK is being used (after initialization) only the specified values will be allowed. 20 values are allowed for each list.

caution

Processing many unique dimension values can be taxing for our servers. A few games with a poor implementation can seriously increase our cost and affect stability. Games will be blocked if they submit too many unique dimension values. We have this configuration requirement to guide users into planning what dimension values can be used.

Use the following actions to be able to configure allowed values:

  • Add currency to available resource currencies
  • Add currency to available resource item types
  • Add currency to available custom 01 dimensions
  • Add currency to available custom 02 dimensions
  • Add currency to available custom 03 dimensions

img

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

Enable/disable event submission

If you for GDPR purposes need to disable event submission you can call the following action:

Toggle event submission

By default event submission is of course enabled. You will still receive configs if you have set any for your game even after disabling event submission.

Initializing

Call the GameAnalytics action to initialize the SDK.

img

info

Remember to set the game key and secret key for your game in Properties section on the GameAnalytics object. The initialize action will also set the info and verbose log, manual session handling and build version based on the values set in the properties section.

img

tip

Don’t have any keys yet? Head over here and register your game at the GameAnalytics website!

Below is a common example of the actions called from the On start of layout:

img