Unreal SDK

Install the SDK

Install the Unreal Engine SDK by downloading the latest version of AmplitudeUnreal.zip found on the GitHub releases page.
Unzip it into a folder inside your Unreal project's Plugins directory.

1mkdir -p Plugins/AmplitudeUnreal
2unzip AmplitudeUnreal.zip -d Plugins/AmplitudeUnreal

Enable the SDK plugin in the editor

Open your project in the UE4 editor. Navigate to Settings > Plugins > Project > Analytics and make sure to enable AmplitudeUnreal.

Enable Amplitude as the analytics provider

Navigate 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, you should include the necessary Unreal Engine analytics headers.

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

Use and examples

The API of Amplitude Unreal follows the analytics provider interface defined by the Unreal Engine.

Log basic events

Events represent how users interact with your app. For example, "Game Started" may be an action you want to note.

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

Log events with properties

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

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

Set user properties

User properties help you understand your users at the time they performed some action within your app.

The generic Unreal Engine IAnalyticsProvider supports a limited number of user properties.

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

Set custom user IDs

If your app has its login system that you want to track users with, use SetUserId to set a custom user ID.

1FAnalytics::Get().GetDefaultConfiguredProvider()->SetUserID(TEXT("test123@test.com"));
Was this page helpful?

Thanks for your feedback!

July 23rd, 2024

Need help? Contact Support

Visit Amplitude.com

Have a look at the Amplitude Blog

Learn more at Amplitude Academy

© 2024 Amplitude, Inc. All rights reserved. Amplitude is a registered trademark of Amplitude, Inc.