GitHubレポジトリへのリンク

AppsFlyer Unreal Steam SDK integration

AppsFlyerは、クロスプラットフォームアトリビューションを実行するための強力なツールを提供することで、ゲームマーケティング担当者がより良い意思決定を行えるよう支援します。

ゲームのアトリビューションには、初回開封、連続セッション、アプリ内イベントを記録するAppsFlyer SDKを統合することが必要です。(例:購入など)
AppsFlyer SDKをUnreal Steamゲームに組み込む際の参考として、このサンプルアプリを使用することをお勧めします。注:以下のサンプルコードは、現在、Windows環境でのみサポートされています。


前提条件

  • Unreal Engine 4.2x
  • Steamworks SDKが実装されたUE4(通常、UE4のサードパーティに含まれているため、ダウンロードする必要はありません)
  • Steamクライアントがアクティブなユーザーでインストールされている

AppsflyerSteamModule - Interface

AppsflyerSteamModule.h, included in the appsflyer-unreal-steam-sample-app/AppsflyerSteamIntegrationFiles/AppsflyerSteamModule 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)

例:

AppsflyerSteamModule()->init("DEV_KEY", "STEAM_APP_ID");

Arguments:

  • STEAM_APP_IDSteamDBから取得できます。
  • DEV_KEY: Get from the marketer or AppsFlyer HQ.

Start

このメソッドは、AppsFlyerに first open / session(初回起動 / セッション)のリクエストを送信します。

メソッドのシグネチャ

void start(bool skipFirst = false)

例:

// without the flag
AppsflyerSteamModule()->start();

// with the flag
bool skipFirst = [SOME_CONDITION];
AppsflyerSteamModule()->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}";
AppsflyerSteamModule()->logEvent(event_name, event_values);

IsInstallOlderThanDate

このメソッドは日付文字列を受け取り、ゲームフォルダの修正日が日付文字列より古い場合に true を返します。日付の文字列形式: "2023-January-01 23:12:34"

メソッドのシグネチャ

bool isInstallOlderThanDate(std::string datestring)

例:

// the modification date in this example is "2023-January-23 08:30:00"

// will return false
bool dateBefore = AppsflyerSteamModule()->isInstallOlderThanDate("2023-January-01 23:12:34");

// will return true
bool dateAfter = AppsflyerSteamModule()->isInstallOlderThanDate("2023-April-10 23:12:34");

サンプルアプリの実行

  1. UE4エンジンを開きます。
  2. New Project -> Games -> First Person を選択します。
  3. (Blueprintsの代わりに)C++を選択します。
  4. Name the project AppsFlyerSample and click Create project.
  5. Follow the instructions to implement AppsFlyer in your Steam game.
  6. UE4エンジンエディターからサンプルアプリを起動します。
  7. 24時間後にダッシュボードが更新され、オーガニックとノンオーガニックのインストールとアプリ内イベントが表示されます。

SteamゲームにAppsFlyerを実装する

Setup

  1. UE4のサードパーティにSteamが含まれていることを確認します。詳細はこちら
  2. Add the following definitions to Config/DefaultEngine.ini. For reference, see the appsflyer-unreal-steam-sample-app/AppsflyerSteamIntegrationFiles/DefaultEngine.ini file.
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")
DefaultPlatformService=Steam
bEnabled=true
SteamDevAppId=480 //replace "480" with your steam app id.
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"
  1. Unreal editorでPluginsを開き、Online Subsystem Steamを有効にしてから、エディターを再起動します。
  2. Open the project in your preferred C++ editor and in [YOUR-APP-NAME].Build.cs file, add OpenSSL, OnlineSubsystem, and OnlineSubsystemSteam to your dependencies and HTTP as a private dependency:
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "OpenSSL", "OnlineSubsystem", "OnlineSubsystemSteam" });
PrivateDependencyModuleNames.Add("HTTP");
  1. Unreal Projectファイルの Sourceディレクトリの下に、AppsflyerSteamModule という名前の新しいディレクトリを作成します。
  2. Copy the following files from appsflyer-unreal-steam-sample-app/AppsflyerSteamIntegrationFiles/AppsflyerSteamModule to the new folder:
  • AppsflyerModule.cpp
  • AppsflyerSteamModule.cpp
  • AppsflyerSteamModule.h
  • DeviceID.h
  • RequestData.h
  1. プロジェクトファイルを生成し、SSLを開きます。詳細はこちら
  2. In the GameMode.h file, add the StartPlay() function:
class AAppsFlyerSampleGameMode : public AGameModeBase
{
    GENERATED_BODY()

public:
    AAppsFlyerSampleGameMode();
    virtual void StartPlay() override;
};

  1. Open the Source/AppsFlyerSample/AppsFlyerSampleGameMode.cpp file and add the following include to your GameMode.cpp file:
#include "AppsflyerSteamModule/AppsflyerSteamModule.cpp"
  1. Add the following function, making sure to replace DEV_KEY and STEAM_APP_ID in the init function with your app details:
void AAppsFlyerSampleGameMode::StartPlay()
{
    Super::StartPlay();
    if (SteamAPI_Init()) {
        // init the AF module
        AppsflyerSteamModule()->init("DEV_KEY", "STEAM_APP_ID")

        // check whether the install date was not older than 2023-January-02 23:12:34
        bool isInstallOlderThanDate = AppsflyerSteamModule()->isInstallOlderThanDate("2023-January-02 23:12:34");

        // send the firstOpen/session event (if the install date is not older than the given date, the AF module will skip the first-open event)
        AppsflyerSteamModule()->start(!isInstallOlderThanDate);

        // Use the following code to send in-app event
        // 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}";
        AppsflyerSteamModule()->logEvent(event_name, event_values);
    }
}
  1. AppsFlyer連携をInitialize(初期化)しstart(開始)します。
  2. Report in-app events.

Steamのクラウドセーブを削除する(アトリビューションをリセットする)

  1. Steamクラウドを無効化
  2. ローカルファイルの削除