Native PC Unreal
리포지토리에 연결
GitHub
AppsFlyer Native PC Unreal SDK integration
는 앱스플라이어크로스 플랫폼 어트리뷰션을 수행할 수 있는 강력한 도구를 제공하여 게임 마케터가 더 나은 결정을 내릴 수 있도록 지원합니다.
Game attribution requires the game to integrate the AppsFlyer SDK that records first opens, consecutive sessions, and in-app events. For example, purchase events.
We recommend you use this sample app as a reference for integrating the AppsFlyer SDK into your Unreal game.
Note: The sample code that follows is currently only supported in a Windows environment.
Prerequisites
- Unreal 엔진 4.2x
AppsflyerPCModule - Interface
AppsflyerPCModule.h
는 appsflyer-native-pc-unreal-sample-app/AppsflyerPCModule
폴더에 있으며 앱스플라이어 서버에 연결하고 이벤트를 리포트하는 데 필요한 코드 및 논리가 포함되어 있습니다.
Init
이 메서드는 API 키와 앱 ID를 수신하고 앱스플라이어 모듈을 초기화합니다.
Method signature
void Init(const char* devkey, const char* appID)
Arguments:
DEV_KEY
: 마케터 또는 앱스플라이어 본사에서 얻을 수 있습니다.APP_ID
: Your Appsflyer app id (excluding thenativepc-
제외).
Usage:
AppsflyerPCModule()->Init(<< DEV_KEY >>, << APP_ID >>);
Start
이 메서드는 앱스플라이어에 first open/session 요청을 보냅니다.
Method signature
void Start(bool skipFirst = false)
인수
bool skipFirst
: Determines whether or not to skip first open events and send session events. The value is false by default. If true , first open events are skipped and session events are sent. See example
Usage:
// without the flag
AppsflyerPCModule()->Start();
// with the flag
bool skipFirst = [SOME_CONDITION];
AppsflyerPCModule()->Start(skipFirst);
Stop
This method stops the SDK from functioning and communicating with AppsFlyer servers. It's used when implementing user opt-in/opt-out.
Method signature
void Stop()
Usage:
// Starting the SDK
AppsflyerPCModule()->Start();
// ...
// Stopping the SDK, preventing further communication with AppsFlyer
AppsflyerPCModule()->Stop();
LogEvent
이 메서드는 이벤트 이름과 JSON 객체를 수신하고 앱스플라이어에 인앱이벤트를 보냅니다.
Method signature
void LogEvent(std::string event_name, std::string event_values, std::string custom_event_values = "")
인수
std::string event_name
-std::string event_parameters
: dictionary object which contains the predefined event parameters.std::string event_custom_parameters
(non-mandatory): dictionary object which contains the any custom event parameters. For non-English values, please use UTF-8 encoding.
Usage:
// Setting the event parameters json string and event name
std::string event_name = "af_purchase";
std::string event_parameters = "{\"af_currency\":\"USD\",\"af_revenue\":24.12}";
// Send the InApp event request
AppsflyerPCModule()->LogEvent(event_name, event_parameters);
// Set non-English values for testing UTF-8 support
std::wstring ws = L"車B1234 こんにちは";
std::wstring ws2 = L"新人邀约购物日";
std::string event_custom_parameters = "{\"goodsName\":\"" + AppsflyerPCModule()->to_utf8(ws) + "\",\"goodsName2\":\"" + AppsflyerPCModule()->to_utf8(ws2) + "\"}";
// Send inapp event with custom params
AppsflyerPCModule()->LogEvent(event_name, event_parameters, event_custom_parameters);
GetAppsFlyerUID
앱스플라이어의 고유 기기 ID를 가져옵니다. SDK는 앱 설치 시 앱스플라이어의 고유 기기 ID를 생성합니다. SDK가 시작되면 이 ID가 첫 번째 앱 인스톨의 ID로 기록됩니다.
Method signature
std::string GetAppsFlyerUID()
Usage:
AppsflyerPCModule()->GetAppsFlyerUID();
SetCustomerUserId
This method sets a customer ID that enables you to cross-reference your unique ID with the AppsFlyer unique ID and other device IDs. Note: You can only use this method before calling Start()
.
The customer ID is available in raw data reports and in the postbacks sent via API.
Method signature
void SetCustomerUserId(std::string cuid)
Arguments:
std::string cuid
: Custom user id.
Usage:
AppsflyerPCModule()->Init(DEV_KEY, APP_ID);
AppsflyerPCModule()->SetCustomerUserId("Test-18-9-23");
AppsflyerPCModule()->Start();
To_utf8
This method receives a reference of a std::wstring
and returns UTF-8 encoded std::string
Method signature
std::string to_utf8(std::wstring& wide_string);
Usage:
// Set non-English values for testing UTF-8 support
std::wstring ws = L"車B1234 こんにちは";
std::wstring ws2 = L"新人邀约购物日";
std::string event_custom_parameters = "{\"goodsName\":\"" + AppsflyerPCModule()->to_utf8(ws) + "\",\"goodsName2\":\"" + AppsflyerPCModule()->to_utf8(ws2) + "\"}";
IsInstallOlderThanDate
이 메서드는 날짜 문자열을 수신하고 게임 폴더 수정 날짜가 날짜 문자열보다 오래된 경우 true를 반환합니다. 날짜 문자열 형식은 "2023-January-01 23:12:34"입니다.
Method signature
bool IsInstallOlderThanDate(std::string datestring)
Arguments:
std::string datestring
: Date string inyyyy-mm-ddThh:mm:ss+hh:mm
format.
Usage:
// the modification date in this example is "2023-January-23 08:30:00"
// will return false
bool dateBefore = AppsflyerPCModule()->IsInstallOlderThanDate("2023-January-01 23:12:34");
// will return true
bool dateAfter = AppsflyerPCModule()->IsInstallOlderThanDate("2023-April-10 23:12:34");
// example usage with skipFirst:
bool isInstallOlderThanDate = AppsflyerPCModule()->IsInstallOlderThanDate("2023-April-10 23:12:34");
AppsflyerPCModule()->Start(isInstallOlderThanDate);
샘플 앱 실행
- UE4 엔진을 엽니다.
- 신규 프로젝트 -> 게임 -> 1인칭 게임을 선택합니다.
- C++ 를 선택합니다(Blueprints 대신).
- 프로젝트 이름을
AppsFlyerSample
로 지정하고 프로젝트 생성을 클릭합니다. - Follow the instructions to implement AppsFlyer in your game.
- UE4 엔진 에디터에서 샘플 앱을 실행합니다.
- 24시간 후 대시보드가 업데이트되고 오가닉 및 논오가닉 인스톨과 인앱이벤트가 표시됩니다.
Implementing AppsFlyer in your Unreal game
Setup
- 선호하는 C ++ 편집기에서 프로젝트를 연 다음
[YOUR-APP-NAME].Build.cs
파일에OpenSSL
사용자의 의존성 및HTTP
비공개 종속성으로:
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "OpenSSL" });
PrivateDependencyModuleNames.Add("HTTP");
-
In your Unreal Project files, under the
Source/[YOUR-APP-NAME]
directory, create a new directory namedAppsflyerPCModule
. -
여기서
appsflyer-native-pc-unreal-sample-app/AppsflyerPCModule
의 다음 파일을 새 폴더로 복사합니다:- AppsflyerPCModule.cpp
- AppsflyerPCModule.cpp
- AppsflyerPCModule.h
- DeviceID.h
- RequestData.h
-
OpenSSL을 추가할 프로젝트 파일을 생성합니다. 더 알아보기
-
다음
GameMode.h
파일에서 다음 함수를 엽니다:StartPlay()
함수:
UCLASS(minimalapi)
class AAppsFlyerSampleGameMode : public AGameModeBase
{
GENERATED_BODY()
public:
AAppsFlyerSampleGameMode();
virtual void StartPlay() override;
};
- 이
Source/[YOUR-APP-NAME]/AppsFlyerSampleGameMode.cpp
파일을 열고 다음 #include 파일을 GameMode.cpp 파일에 포함하십시오.
#include "AppsflyerPCModule/AppsflyerPCModule.h"
using Super = AGameModeBase;
- 다음 함수를 추가하고
DEV_KEY
andAPP_ID
in theinit
function with your app details, and report in-app events
void AAppsFlyerSampleGameMode::StartPlay()
{
Super::StartPlay();
// af module init
AppsflyerPCModule()->Init(<< DevKey >>, << AppID >>);
// af send firstopen/session
AppsflyerPCModule()->Start();
// set event name
std::string event_name = "af_purchase";
// set json string
std::string event_parameters = "{\"af_currency\":\"USD\",\"af_revenue\":24.12}";
// af send inapp event
AppsflyerPCModule()->LogEvent(event_name, event_parameters);
if (AppsflyerPCModule()->IsInstallOlderThanDate("2025-January-01 23:12:34")) {
UE_LOG(LogTemp, Warning, TEXT("2025-January-01 23:12:34: true"));
}
else {
UE_LOG(LogTemp, Warning, TEXT("2025-January-01 23:12:34: false"));
}
if (AppsflyerPCModule()->IsInstallOlderThanDate("2023-January-01 23:12:34")) {
UE_LOG(LogTemp, Warning, TEXT("2023-January-01 23:12:34: true"));
}
else {
UE_LOG(LogTemp, Warning, TEXT("2023-January-01 23:12:34: false"));
}
// set non-English values for testing UTF-8 support
std::wstring ws = L"車B1234 こんにちは";
std::wstring ws2 = L"新人邀约购物日";
std::string event_custom_parameters = "{\"goodsName\":\"" + AppsflyerPCModule()->to_utf8(ws) + "\",\"goodsName2\":\"" + AppsflyerPCModule()->to_utf8(ws2) + "\"}";
// af send inapp event with custom params
AppsflyerPCModule()->LogEvent(event_name, event_parameters, event_custom_parameters);
// stop the SDK
AppsflyerPCModule()->Stop();
}
Resetting the attribtion
Delete the appsflyer_info
file:
최신 데이터 12개월 전