Setup
This documentation covers GameAnalytics Unreal SDK version 6.0 and newer. If you are using an older version please check the legacy docs here
In this integration guide we will take you through the most important steps of instrumenting your game with the GameAnalytics Unreal SDK.
Installation
- Unreal Marketplace - FAB Store
- Manual Installation
Marketplace Installation
You can download the GameAnalytics plugin directly from the Unreal Marketplace.
After adding GameAnalytics to Unreal verify that the plugin was installed correctly:
- Make sure the Plugin is enabled by clicking
Settings → Plugins. - Check
Installed → Analyticsfor the GameAnalytics plugin. - Check
Built-In → Analyticsfor enabling the Analytics Blueprint Library
Finally, add the following to your project’s DefaultEngine.ini file located in the Config folder.
[Analytics]
ProviderModuleName=GameAnalytics
And include the GameAnalytics header file to wherever you are using the SDK:
#include "GameAnalytics.h"
#include "GameAnalyticsModule.h"
Manual Installation
Alternatively you can download the plugin from our github page.
There are 2 ways of installing the plugin manually:
- Integrating into the engine full source version (editor compiling)
- Installing into a specific project (using pre-compiled editor)
Full Source Version
When using the full source version you compile the Unreal Editor yourself. It is possible to add the plugin at this stage to be part of the engine and available for all projects created using that compiled version.
Navigate to your Unreal Engine directory and place the GameAnalytics folder inside the folder EnginePluginsRuntimeAnalytics
Specific Project (using pre-compiled editor)
A pre-compiled editor can be downloaded through the Epic Games Launcher or built from source. When GameAnalytics is not part of the editor it needs to be added to the specific project.
Add the GameAnalytics folder to a Plugins subfolder in your specific project folder. If this Plugins subfolder doesn’t exist then create one.
Finally you can compile the project.
The project has to be a C++ project for the plugin to work! A pure blueprint project won't work.
Activating the plugin
In order to activate the plugin you need to follow the steps below:
- Restart the Unreal Editor
- Open the Plugins menu (
Window > Plugins) - Under Analytics enable the
GameAnalyticsplugin - Enable the
Blueprint Analytics Framework(if you are using blueprints) - You will be prompted to restart the editor again
Finally, add the following to your project’s
DefaultEngine.inifile located in theConfigfolder
[Analytics]
ProviderModuleName=GameAnalytics
Using GameAnalytics from C++
If you are planning to use the GameAnalytics SDK directly from your C++ code you need to add GameAnalytics to PrivateDependencyModuleNames and PrivateIncludePathModuleNames in your project’s *.Build.cs file:
PrivateDependencyModuleNames.AddRange(new string[] { "GameAnalytics" });
PrivateIncludePathModuleNames.AddRange(new string[] { "GameAnalytics" });
Sign Up
Account Creation
If you have not already, you can register for a GameAnalytics accounts via our online form here.
After you have signed up you will be asked to create a studio and a game. If your game is already published and on an app store you can search for it using the provided search field or else you can create it manually.
Login
Inside the Account tab you can login to a GameAnalytics account directly in the editor.
Login through Project Settings allows you to select your studio and game for each platform. When selected the game key and the secret key will be automatically fetched and configured.
You can always locate the keys in our tool via game settings.
To use GameAnalytics you need a game key and a secret key for each platform you are using (i.e: for a mobile game that may be both iOS and Android).
The game key is a unique identifier for your game while the secret key is used to protect event data from being tampered with as it travels to the GameAnalytics servers.
Once a game has been created it can take a few minutes before the GameAnalytics servers will accept events for that game
Initializing the SDK
There are two ways of using the GameAnalytics plugin inside your C++ code:
- directly using an instance of an
UGameAnalyticsobject - using the
IAnalyticsProviderinterface
The former will provide all the plugin features, including remote configurations and performance tracking. The IAnalyticsProvider will provide an easier integration inside Unreal, but will only expose limited features.
Due to the inner workings of the module the IAnalyticsProvider will retrieve its settings from Project Settings -> Plugins -> GameAnalytics. While using UGameAnalytics directly will require you to manually call the setup functions (either from C++ or Blueprints).
If you are using the IAnalyticsInterface, but desire to enable advanced features of the SDK, you can safely mix calls from both IAnalyticsInterface and UGameAnalytics as both are using the same instance inside the module (provided you initialize the SDK only once).
- C++ Code
- IAnalyticsProvider
- Blueprints
Initialization
The UGameAnalytics class provides all plugin functionality. The GameAnalytics module will hold an instance of UGameAnalytics*.
Add the headers to your project:
#include "GameAnalytics.h"
#include "GameAnalyticsModule.h"
Initialize the SDK:
UGameAnalytics* GameAnalytics = FGameAnalyticsModule::Get().GetInstance();
// initialize the SDK with your keys
GameAnalytics->Initialize(GAME_KEY, SECRET_KEY);
Using IAnalyticsProvider
GameAnalytics also proivdes a IAnalyticsProvider implementation for seamless integration inside the Unreal ecosystem.
The IAnalyticsProvider interface will retrieve its configuration from Project Settings -> Plugins -> GameAnalytics (e.g: game keys, resources, info/verbose log).
TSharedPtr<IAnalyticsProvider> AnalyticsProvider = FGameAnalyticsModule::Get().CreateAnalyticsProvider(FGameAnalyticsModule::Delegate());
// start session will invoke UGameAnalytics::Initialize on first call
AnalyticsProvider->StartSession();
From Blueprints
You will have to create an instance of UGameAnalytics directly from blueprints. Make sure your object will not be garbage collected while still in use.
