Skip to main content

Setup

Installation

Gamemaker Studio 1

Download the SDK from our github repository and follow the next steps:

  • Unzip the downloaded .zip
  • Open Game Maker: Studio and right-click on the Extensions folder and click on Import extension
  • Select the .gmez file from the unzipped file
  • Right-click on the newly imported extension and click on Properties and then on Import Resources and finally click on Import All in the import pop-up window
info

(Android users only) Make sure you have Google Play Services 9.4.0 installed through the Android SDK Manager or else you will get compile errors like this:

Could not find com.google.android.gms:play-services-base:9.4.0
Gamemaker Studio 2

Gamemaker Studio 2

To download GameAnalytics SDK for Gamemaker Studio 2 go to GameMaker marketplace.

info

The Gamemaker Studio 2 download link can only seen on the marketplace page by users with a paid Gamemaker Studio 2 license. This is apparently a standard behaviour for all Gamemaker Studio 2 extensions.

Initialization

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 at the beginning of the game for example inside the Creation code of a room.

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

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 build version
ga_configureBuild("android 1.0.0");

Custom userId

The SDK will automatically generate an 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 app lifetime when you need.

ga_configureUserId("user1234567879");

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.

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.

{
var array = ga_array("gems", "gold");
ga_configureAvailableResourceCurrencies(array);
}
{
var array = ga_array("boost", "lives");
ga_configureAvailableResourceItemTypes(array);
}
{
var array = ga_array("ninja", "samurai");
ga_configureAvailableCustomDimensions01(array);
}
{
var array = ga_array("whale", "dolphin");
ga_configureAvailableCustomDimensions02(array);
}
{
var array = ga_array("horde", "alliance");
ga_configureAvailableCustomDimensions03(array);
}
info

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:

ga_setEnabledEventSubmission(false);

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.

Initialize Call

Call this method to initialize using the game key and secret key for your game.

// Initialize
ga_initialize("[game key]", "[secret key]");
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 code placed in the Creation code of a room.

// ... other code from your project ...

ga_setEnabledInfoLog(true);
ga_setEnabledVerboseLog(true);

ga_configureBuild("0.10");

{
var array = ga_array("gems", "gold");
ga_configureAvailableResourceCurrencies(array);
}
{
var array = ga_array("boost", "lives");
ga_configureAvailableResourceItemTypes(array);
}
{
var array = ga_array("ninja", "samurai");
ga_configureAvailableCustomDimensions01(array);
}
{
var array = ga_array("whale", "dolphin");
ga_configureAvailableCustomDimensions02(array);
}
{
var array = ga_array("horde", "alliance");
ga_configureAvailableCustomDimensions03(array);
}

ga_initialize("[game key]", "[secret key]");