# Unreal SDK

Reference for the Unreal Engine plugin that sends events to Amplitude from your Unreal project.

Source: https://amplitude.com/docs/sdks/analytics/unreal/unreal-sdk

---

On this page

- [Install the SDK](#install-the-sdk)
- [Enable the SDK plugin in the editor](#enable-the-sdk-plugin-in-the-editor)
- [Enable Amplitude as the analytics provider](#enable-amplitude-as-the-analytics-provider)
- [Include the required analytics modules](#include-the-required-analytics-modules)
- [Track events and user properties](#track-events-and-user-properties)
- [Log basic events](#log-basic-events)
- [Log events with properties](#log-events-with-properties)
- [Set user properties](#set-user-properties)
- [Set custom user IDs](#set-custom-user-ids)

# Unreal SDK

[githubAmplitude-Unreal](https://github.com/amplitude/Amplitude-Unreal)

## Install the SDK

Download the latest version of `AmplitudeUnreal.zip` from the [GitHub releases](https://github.com/amplitude/Amplitude-Unreal/releases/latest) page. Unzip the file into a folder inside your Unreal project's `Plugins` directory.

bash

```
mkdir -p Plugins/AmplitudeUnreal
unzip AmplitudeUnreal.zip -d Plugins/AmplitudeUnreal

### Enable the SDK plugin in the editor

Open your project in the UE4 editor. Go to *Settings > Plugins > Project > Analytics* and enable `AmplitudeUnreal`.

### Enable Amplitude as the analytics provider

Go to *Settings > Project Settings > Analytics > Amplitude* and fill in the fields with your API key.

### Include the required analytics modules

In any file that involves instrumentation, include the Unreal Engine analytics headers.

cpp

#include "Runtime/Analytics/Analytics/Public/Analytics.h"
#include "Runtime/Analytics/Analytics/Public/Interfaces/IAnalyticsProvider.h"

## Track events and user properties

The Amplitude Unreal API follows the [analytics provider interface](https://docs.unrealengine.com/en-US/API/Runtime/Analytics/Interfaces/IAnalyticsProvider/index.html) that Unreal Engine defines.

### Log basic events

Events represent how users interact with your app. For example, you can track a `Game Started` event.

FAnalytics::Get().GetDefaultConfiguredProvider()->StartSession();
FAnalytics::Get().GetDefaultConfiguredProvider()->RecordEvent(TEXT("Game started"));
FAnalytics::Get().GetDefaultConfiguredProvider()->EndSession();

### Log events with properties

Events can contain properties. Properties give context about the event.

TArray<FAnalyticsEventAttribute> AppendedAttributes;
AppendedAttributes.Emplace(TEXT("Test Event Prop key1"), TEXT("Test Event value1"));
AppendedAttributes.Emplace(TEXT("Test Event Prop key2"), TEXT("Test Event value2"));
FAnalytics::Get().GetDefaultConfiguredProvider()->RecordEvent(TEXT("Game Started"), AppendedAttributes);

### Set user properties

User properties describe your users at the time they take an action in your app.

The generic Unreal Engine [`IAnalyticsProvider`](https://docs.unrealengine.com/en-US/API/Runtime/Analytics/Interfaces/IAnalyticsProvider/index.html) supports a limited number of user properties.

FAnalytics::Get().GetDefaultConfiguredProvider()->SetLocation(TEXT("Test location"));
FAnalytics::Get().GetDefaultConfiguredProvider()->SetGender(TEXT("Test gender"));
FAnalytics::Get().GetDefaultConfiguredProvider()->SetAge(TEXT(27));

### Set custom user IDs

If your app has its own login system, use `SetUserId` to set a custom user ID.

FAnalytics::Get().GetDefaultConfiguredProvider()->SetUserID(TEXT("test123@test.com"));

Was this helpful?

<!--$-->

<!--/$-->
