# Unreal Engine SDK Import Integration You can start sending the data from your [Unreal Engine](https://www.unrealengine.com/) app to Treasure Data, using our Unreal Engine SDK. Visit the following repository for more information. ![](/assets/image-20191022-132426.f322f86a09d78e50b2c307af1257421ea14e3b6fc60f4ed28604bd3eedc1d4b1.3fd85dbb.png) - [Unreal Engine 4 SDK Repository](https://github.com/treasure-data/td-ue4-sdk) ## Requirements - Unreal Engine 4.14 - Treasure Data Write-Only API Key (Select **User** > **API Keys**) ## Getting Started 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 as follows: ``` UnrealEngine/Engine/Plugins/td-ue4-sdk ``` > Alternatively, 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**: - GenerateProjectFiles.bat - GenerateProjectFiles.sh Depending on 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. When the command finishes, type the *make* command: ```bash $ make ``` After a few seconds, the plugin binary is 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: ```bash $ 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 ![](/assets/image-20191022-132504.d8ef25004a8914d9aeb816f1eb52423fec61361b2651eb26a106463e80f05c0e.3fd85dbb.png)![](/assets/image-20191022-132513.795ddcb8d26225801bc0bb865cdde797762f202f6828b83cca73769d289dd941.3fd85dbb.png) ## Configure Project Settings From your project directory, open and edit the file *Config/DefaultEngine.ini* and append the following content at the bottom: ```c++ [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, select the Blueprints drop-down menu and select the *Open Level Blueprint* option: ![](/assets/image-20191022-132603.0ebbdf6e5796a5cd6d2ad8fb6e0450ebc3a4dcd3b66aebc89b8ce7d24ff9a8b6.3fd85dbb.png) 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. ## Treasure Data To query the game events, go to the TD Console, select **Databases**, and open the database used in the game (Config/DefaultEngine.ini > TDDatabase): ![](/assets/image-20191022-132637.e2074fcadb175961c18432787b104e2c10deac7024895099460750092f25a6a8.3fd85dbb.png) By default two tables are created: - Sessions: start and stop sessions - Events: All events with or without attributes. To query records select a table name and select the *Query* button. By default you can issue a SQL query as in the following example: ```sql SELECT * from events; ``` ![](/assets/image-20191022-132726.316a30dce56d38fcfeaf69fc5934c01f73f7b3bf0802ed8f0a9a6c1b8c16e3d0.3fd85dbb.png)