This article will help you start sending the data from your Unreal Engine app to Arm Treasure Data, using our Unreal Engine SDK. Please visit the repository below for more information.
- Unreal Engine 4.14
- Treasure Data Write-Only API Key (Click on User > API Keys)
The following document assumes that the current Unreal Engine has been compiled from sources or it has all dependencies so third-party plugins can be built.
Download and place the plugin
Get a copy of the plugin from the main GIT repository:
$ git clone http://github.com/treasure-data/td-ue4-sdk
Copy the new td-ue4-sdk to your Engine plugins folder, the target path looks like:
Alternative you can copy the plugin content inside your Project Plugin directory, not that this approach don't work on Linux Development environment.
Build the plugin
To build the plugin is required to generate the build-rules, for the purpose the UE4 Engine provides a script called GenerateProjectFiles:
Depending of the system (Unix bases or Window), run the proper script from the command line:
- If the plugin is inside the Project directory (Project/Plugins), go to the Project root directory and run the script.
- If the plugin is inside the Engine, run the command from the Unreal Engine source root directory.
Once the command have finished, type the make command:
After a few seconds the plugin binary should be available.
Speed up plugin build phase
In some cases is required to re-build only the plugin, using a normal make command can take some minutes as it does some parsing running some scripts to fix dependencies, to speed up the process the following options can be added:
$ make UE4Editor ARGS=-canskiplink
Enable the Analytics plugins for your project
Inside the Unreal Engine 4 Editor, open your project and the plugins window:
- Edit > Plugins
Now enable the two required plugins:
- Blueprints: located at Built-in > Analytics
- Treasure Data: located at Installed > Analytics
Configure Project settings
From your project directory, open and edit the file Config/DefaultEngine.ini and append the following content at bottom:
[Analytics] ProviderModuleName=TreasureData TDApiKey=TD-WRITE-ONLY-KEY TDDatabase=DATABASE_NAME SendInterval=10 [AnalyticsDevelopment] ProviderModuleName=TreasureData TDApiKey=TD-WRITE-ONLY-KEY TDDatabase=DATABASE_NAME SendInterval=10 [AnalyticsTest] ProviderModuleName=TreasureData TDApiKey=TD-WRITE-ONLY-KEY TDDatabase=DATABASE_NAME SendInterval=10
Save the file and restart Unreal Engine Editor.
Gather metrics through Blueprints
In the Editor, click on the Blueprints drop-down menu and click on the Open Level Blueprint option:
Now in the Event graphs, different events can be connected to Analytics functions, as an example, the following image demonstrates how to track the Session Start, Session End and Record Event w/Attributes events:
After a Game starts, the plugin will send the events to Treasure Data.
To query the game events, go to the Treasure Data Console, click on the Databases item (left menu) and open the database used in the game (Config/DefaultEngine.ini > TDDatabase):
By default two tables are created:
- Sessions: start and stop sessions
- Events: All events with or without attributes.
To query records just click on any table name and click on the Query top button. By default you can issue a SQL query as in the following example:
SELECT * from events;