On this page

For AI agents: a documentation index is available at /docs/llms.txt. Append .md to any page URL for markdown, or send Accept: text/markdown.

Unreal SDK

SDKをインストールする

GitHubのリリースページからAmplitudeUnreal.zipの最新バージョンをダウンロードしてください。ファイルをUnrealプロジェクトのPluginsディレクトリ内のフォルダに解凍します。

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

エディタで SDK プラグインを有効にする

UE4 エディタでプロジェクトを開きます。 設定 > プラグイン > プロジェクト > アナリティクスに移動し、AmplitudeUnrealを有効にします。

Amplitudeをアナリティクスプロバイダーとして有効にする

設定 > プロジェクト設定 > アナリティクス > Amplitudeに移動し、APIキーをフィールドに入力します。

必要なアナリティクスモジュールを含める

インストルメンテーションを含むファイルには、Unreal Engineのアナリティクスヘッダーを含めます。

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

イベントとユーザープロパティの追跡

Amplitude Unreal API は、Unreal Engine が定義したアナリティクスプロバイダーインターフェイスに従います。

基本イベントの記録

イベントは、ユーザーがアプリとどのようにやり取りするかを表します。 たとえば、Game Startedイベントを追跡できます。

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

イベントをプロパティとともに記録

イベントにはプロパティを含めることができます。 プロパティはイベントに関するコンテキストを提供します。

cpp
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);

ユーザープロパティを設定する

ユーザープロパティは、ユーザーがアプリ内でアクションを実行した時点でのユーザーのことを表します。

汎用Unreal EngineのIAnalyticsProviderは、ユーザープロパティを限定的にサポートしています。

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

カスタムユーザーIDを設定する

アプリに独自のログインシステムがある場合は、SetUserIdを使用してカスタムユーザーIDを設定します。

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

Was this helpful?