Steam C++
AppsFlyer Steam C++ SDK integration
AppsFlyerは、クロスプラットフォームアトリビューション、モバイルおよびウェブ分析、ディープリンク、不正検出、プライバシー管理と保全など、実際のペインポイントを解決する強力なツールを提供することで、ゲームマーケティング担当者がより良い意思決定を行えるように支援します。
ゲームのアトリビューションには、ゲームがHTTPSでAppsFlyerのAPIと通信し、初回起動、連続セッション、アプリ内イベントなどのユーザーアクティビティをレポートすることが必要です。(例:購入など)このサンプルアプリは、ユーザーのアクティビティをレポートするコードをC++に実装するためのリファレンスとして使用することをお勧めします。注:以下のサンプルコードは、現在、Windows環境でのみサポートされています。
前提条件:
- あなたのプロジェクトに Steamworks SDKが実装されている
- vcpkg openssl & nlohmann-jsonパッケージ:
vcpkg install nlohmann-json:x86-windows vcpkg install openssl:x86-windows
AppsflyerSteamModule - Interface
AppsflyerSteamModule.h”, included in the appsflyer-module
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_ID
SteamDBから取得できます。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)
例:
json event_values = { {"af_currency", "USD"}, {"af_price", 6.66}, {"af_revenue", 24.12} };
std::string event_name = "af_purchase";
AppsflyerSteamModule()->logEvent(event_name, event_values);
注意:JSONを使用するためには、必ず以下のインポートを使用してください:
#include <nlohmann/json.hpp>
using json = nlohmann::json;
OnCallbackSuccess, OnCallbackFailure
上記のメソッドは、成功/失敗時に必要なアクションのプレースホルダーです。
各機能内 (“FIRST_OPEN_REQUEST”, ”SESSION_REQUEST”, ”INAPP_EVENT_REQUEST”) のコンテキストのスイッチケースで、異なる種類のイベントを処理することが可能です。
メソッドのシグネチャ
void onCallbackSuccess(long responseCode, uint64 context)
void onCallbackFailure(long responseCode, uint64 context)
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");
サンプルアプリの実行
- Visual Studioをインストールします。
- ソリューションを開く
../appsflyer-steam-sample-app/steam-sample-app/steamworksexample/SteamworksExample.sln
. - Open the
Source Files/Main.cpp
file. - On line 244, replace
DEV_KEY
andSTEAM_APP_ID
with your app details. - 上部のツールバー(Local Windows Debugger)のPlayをクリックして、アプリを実行します。モードがDebugに設定されていることを確認します。
- 24時間後にダッシュボードが更新され、オーガニックとノンオーガニックのインストールとアプリ内イベントが表示されます。
SteamゲームにAppsFlyerを実装する
Setup
- Copy the files from the
appsflyer-module
folder into your C++ project under Header Files > AppsFlyer. - モジュールをインポート:
#include "AppsflyerSteamModule.h"
- インポート
nlohmann-json
.#include <nlohmann/json.hpp> using json = nlohmann::json;
- AppsFlyer連携を初期化します。
- Report in-app events.
更新済 10日前