Unreal Epic
AppsFlyer Unreal Epic SDK連携
AppsFlyerは、クロスプラットフォームアトリビューションを実行するための強力なツールを提供することで、ゲームマーケティング担当者がより良い意思決定を行えるよう支援します。
ゲームのアトリビューションには、初回起動、連続セッション、アプリ内イベントを記録するAppsFlyer SDKを実装することが必要です。(例:購入など)
AppsFlyer SDKをUnreal Epicゲームに組み込む際の参考として、このサンプルアプリを使用することをお勧めします。注:以下のサンプルコードは、現在、Windows環境でのみサポートされています。
前提条件:
- Unreal Engine 4.2x.
- EOS Subsystemが実装されたUE4(通常、UE4のサードパーティに含まれているため、ダウンロードする必要はありません)
AppsflyerEpicModule - Interface
AppsflyerEpicModule.h
, included in the appsflyer-unreal-epic-sample-app/AppsflyerEpicIntegrationFiles/AppsflyerEpicModule
folder, contains the required code and logic to connect to AppsFlyer servers and report events.
Init
このメソッドは、お客様のAPIキーとアプリIDを受け取り、AppsFlyer Moduleを初期化します。
メソッドのシグネチャ
void init(const char* devkey, const char* appID)
例:
AppsflyerEpicModule()->init("DEV_KEY", "STEAM_APP_ID");
Arguments:
STEAM_APP_ID
SteamDBから取得できます。DEV_KEY
: Get from the marketer or AppsFlyer HQ.
Start
このメソッドは、first open / session(初回起動 / セッション)リクエストをAppsFlyerに送信します。
メソッドのシグネチャ
void start(bool skipFirst = false)
例:
// without the flag
AppsflyerEpicModule()->start();
// with the flag
bool skipFirst = [SOME_CONDITION];
AppsflyerEpicModule()->start(skipFirst);
LogEvent
このメソッドは、イベント名とJSONオブジェクトを受け取り、アプリ内イベントをAppsFlyerに送信します。
メソッドのシグネチャ
void logEvent(std::string event_name, json event_values)
例:
//set event name
std::string event_name = "af_purchase";
//set json string
std::string event_values = "{\"af_currency\":\"USD\",\"af_price\":6.66,\"af_revenue\":24.12}";
AppsflyerEpicModule()->logEvent(event_name, event_values);
サンプルアプリの実行
- UE4エンジンを開きます。
- New Project -> Games -> First Person を選択します。
- (Blueprintsの代わりに)C++を選択します。
- Name the project
AppsFlyerSample
and click Create project. - 指示に従って、EpicゲームにAppsFlyerを実装してください。
- UE4エンジンエディターからサンプルアプリを起動します。
- 24時間後にダッシュボードが更新され、オーガニックとノンオーガニックのインストールとアプリ内イベントが表示されます。
EpicゲームにAppsFlyerを実装する
Setup
- UE4のサードパーティにEpicが入っていることを確認してください。詳細はこちら
- Add the following definitions to
Config/DefaultEngine.ini
while replacing theconfidential
credentials with your EOS credentials. For reference, see theappsflyer-unreal-Epic-sample-app/AppsflyerEpicIntegrationFiles/DefaultEngine.ini
file.
[OnlineSubsystem]
DefaultPlatformService=EOSPlus
[OnlineSubsystemEOS]
bEnabled=true
[OnlineSubsystemEOSPlus]
bEnabled=true
[/Script/OnlineSubsystemEOS.NetDriverEOS]
bIsUsingP2PSockets=true
NetConnectionClassName="OnlineSubsystemEOS.NetConnectionEOS"
[/Script/OnlineSubsystemEOS.EOSSettings]
CacheDir=CacheDir
DefaultArtifactName=Confidential
TickBudgetInMilliseconds=0
bEnableOverlay=False
bEnableSocialOverlay=False
bShouldEnforceBeingLaunchedByEGS=False
TitleStorageReadChunkLength=0
+Artifacts=(ArtifactName="Confidential",ClientId="Confidential",ClientSecret="Confidential",ProductId="Confidential",SandboxId="Confidential",DeploymentId="Confidential",EncryptionKey="Confidential")
bUseEAS=False
bUseEOSConnect=True
bMirrorStatsToEOS=False
bMirrorAchievementsToEOS=False
bUseEOSSessions=True
bMirrorPresenceToEAS=False
- Unreal editorでPluginsを開き、Online Subsystem Steamを有効にしてから、エディターを再起動します。
- Open the project in your preferred C++ editor and in the
[YOUR-APP-NAME].Build.cs
file, addOpenSSL
,OnlineSubsystem
, andOnlineSubsystemEOS
to your dependencies andHTTP
as a private dependency:
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "OpenSSL", "OnlineSubsystem", "OnlineSubsystemEOS" });
PrivateDependencyModuleNames.Add("HTTP");
-
Unreal Projectファイルの Sourceディレクトリの下に、AppsflyerSteamModule という名前の新しいディレクトリを作成します。
-
Copy the following files from
appsflyer-unreal-epic-sample-app/AppsflyerEpicIntegrationFiles/AppsflyerEpicModule
to the new folder:- AppsflyerModule.cpp
- AppsflyerEpicModule.cpp
- AppsflyerEpicModule.h
- DeviceID.h
- RequestData.h
-
OpenSSLを追加するためのプロジェクトファイルを生成します。詳細はこちら
-
In the
GameMode.h
file, add theStartPlay()
function:
class AAppsFlyerSampleGameMode : public AGameModeBase
{
GENERATED_BODY()
public:
AAppsFlyerSampleGameMode();
virtual void StartPlay() override;
};
- Open the
Source/AppsFlyerSample/AppsFlyerSampleGameMode.cpp
file and add the following include to your GameMode.cpp file.
#include "AppsflyerEpicModule/AppsflyerEpicModule.cpp"
- Add the following function, making sure to replace
DEV_KEY
andEPIC_APP_ID
in theinit
function with your app details and initialize the EOS SDK with your EOS details.
void AEpicTestGameMode::StartPlay()
{
Super::StartPlay();
EOS_InitializeOptions SDKOptions;
SDKOptions.ApiVersion = EOS_INITIALIZE_API_LATEST;
SDKOptions.AllocateMemoryFunction = NULL;
SDKOptions.ReallocateMemoryFunction = NULL;
SDKOptions.ReleaseMemoryFunction = NULL;
SDKOptions.ProductName = "PRODUCT_NAME";
SDKOptions.ProductVersion = "1.0";
SDKOptions.Reserved = NULL;
SDKOptions.SystemInitializeOptions = NULL;
EOS_EResult res = EOS_Initialize(&SDKOptions);
if (res == EOS_EResult::EOS_Success || res == EOS_EResult::EOS_AlreadyConfigured) {
EOS_Platform_Options PlatformOptions;
PlatformOptions.ApiVersion = EOS_PLATFORM_OPTIONS_API_LATEST;
PlatformOptions.Reserved = NULL;
PlatformOptions.bIsServer = false;
PlatformOptions.EncryptionKey = NULL;
PlatformOptions.OverrideCountryCode = NULL;
PlatformOptions.OverrideLocaleCode = NULL;
PlatformOptions.ProductId = "PRODUCT_ID";
EOS_Platform_ClientCredentials cCreds;
cCreds.ClientId = "CLIENT_ID";
cCreds.ClientSecret = "CLIENT_SECRET";
PlatformOptions.ClientCredentials = cCreds;
PlatformOptions.SandboxId = "SANDBOX_ID";
PlatformOptions.DeploymentId = "DEPLOYMENT_ID";
PlatformOptions.EncryptionKey = "ENCRYPTION_KEY";
EOS_HPlatform platform = EOS_Platform_Create(&PlatformOptions);
// af module init
AppsflyerEpicModule()->init("DEV_KEY", "APP_ID");
// af send firstopen/session
AppsflyerEpicModule()->start();
//set event name
std::string event_name = "af_purchase";
//set json string
std::string event_values = "{\"af_currency\":\"USD\",\"af_price\":6.66,\"af_revenue\":24.12}";
// af send inapp event
AppsflyerEpicModule()->logEvent(event_name, event_values);
}
else {
UE_LOG(LogTemp, Warning, TEXT("EOS FAIL"));
return;
}
}
- Report in-app events
更新済 9日前