Instrumenting Your Game

Using in-game analytics to track player engagement and find balance issues.

Choose your operating system:

Windows

macOS

Linux

The first step in capturing player retention data is to register an analytics provider for your game. This is done via your project's DefaultEngine.ini file. You must register a default provider. Optionally, you can register different providers and account details for different build types of your game (development, testing, and production). The sections below are an example of configuring the Apsalar plugin:

[Analytics]
ProviderModuleName=IOSApsalar
ApiKey=YourAnalyticsKey1
ApiSecret=YourAnalyticsSecret1
SendInterval=60

[AnalyticsDevelopment]
ApiKey=YourAnalyticsKey2
ApiSecret=YourAnalyticsSecret2
SendInterval=60

[AnalyticsTest]
ApiKey=YourAnalyticsKey3
ApiSecret=YourAnalyticsSecret4
SendInterval=60

The [Analytics] section is the default one used and is where you should set the name of the default provider module. In the case above, it is set to the IOSApsalar plugin that is part of the 4.5 release. The ApiKey and ApiSecret fields come from the Apsalar website. Once you create an account, they will give you a key and secret to use.

Once you have it configured for your project, you are ready to start recording analytics events. To get just the basic player retention data, you need to create a session when the game starts up and end it when it is no longer in the foreground. This can be done using the lines of code shown below, or the Blueprint analytics plugin provided in versions 4.5 and later:

FAnalytics::Get().GetDefaultConfiguredProvider()->StartSession();
FAnalytics::Get().GetDefaultConfiguredProvider()->EndSession();

With those calls as part of your game, you will automatically start gathering player retention data. After getting basic player retention data, you can start adding more events to tell you even more about player behavior in your game.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss