Unreal Epic
Enlace al repositorio de
GitHub
Integración del SDK de AppsFlyer con Unreal Epic
AppsFlyer permite a los marketers de gaming tomar mejores decisiones al proporcionarles potentes herramientas para realizar atribuciones multiplataforma.
La atribución de un juego requiere que este integre el SDK de AppsFlyer, que registra los primeros inicios, las sesiones consecutivas y los eventos in-app. Por ejemplo, los eventos de compra.
Te recomendamos que uses esta aplicación de muestra como referencia para integrar el SDK de AppsFlyer en tu juego de Unreal Epic. Nota: El código de ejemplo que sigue actualmente solo se admite en un entorno Windows.
Requisitos previos:
- Unreal Engine 4.2x.
- Subsistema EOS integrado dentro de tu UE4 (generalmente está incluido en los recursos de terceros de UE4 y no es necesario descargarlo).
AppsflyerEpicModule - Interfaz
AppsflyerEpicModule.h
, incluido en appsflyer-unreal-epic-sample-app/AppsflyerEpicIntegrationFiles/AppsflyerEpicModule
, contiene el código y la lógica necesarios para conectarse a los servidores de AppsFlyer y reportar eventos.
Init
Este método recibe tu clave API e ID de aplicación e inicializa el módulo AppsFlyer.
Firma de método
void init(const char* devkey, const char* appID)
Usage:
AppsflyerEpicModule()->init("DEV_KEY", "STEAM_APP_ID");
Arguments:
STEAM_APP_ID
: se encuentra en SteamDB.DEV_KEY
: puedes obtenerlo del marketer o en AppsFlyer HQ.
Start
This method sends first open/session requests to AppsFlyer.
Firma de método
void start(bool skipFirst = false)
Usage:
// without the flag
AppsflyerEpicModule()->start();
// with the flag
bool skipFirst = [SOME_CONDITION];
AppsflyerEpicModule()->start(skipFirst);
LogEvent
Este método recibe un nombre de evento y un objeto json y envía eventos in-app a AppsFlyer.
Firma de método
void logEvent(std::string event_name, json event_values)
Usage:
//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);
Ejecución de la aplicación de muestra
- Abre el motor de UE4.
- Elige New Project (Nuevo proyecto) > Games (Juegos) > First Person (Primera persona).
- Selecciona C++ (en lugar de Blueprints).
- Nombra el proyecto
AppsFlyerSample
y haz clic en Create project (Crear proyecto). - Sigue las instrucciones para implementar AppsFlyer en tu juego de Epic.
- Inicia la aplicación de muestra desde el editor del motor de UE4.
- Después de 24 horas, el panel de control se actualiza y muestra las instalaciones orgánicas y no orgánicas y los eventos in-app.
Implementación de AppsFlyer en tu juego de Epic
Setup
- Asegúrate de que Epic esté en tus recursos de terceros de UE4. Aprender más
- Agrega las siguientes definiciones a
Config/DefaultEngine.ini
cuando reemplaces las credencialesconfidential
con tus credenciales de EOS. . Como referencia, consulta el archivoappsflyer-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
- En tu editor de Unreal, ve a Plugins, activa Online Subsystem Steam y reinicia el editor.
- Abre el proyecto en tu editor de C++ preferido y en el archivo
[YOUR-APP-NAME].Build.cs
, y agregaOpenSSL
,OnlineSubsystem
yOnlineSubsystemEOS
to your dependencies andHTTP
as a private dependency:
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "OpenSSL", "OnlineSubsystem", "OnlineSubsystemEOS" });
PrivateDependencyModuleNames.Add("HTTP");
-
En tus archivos de Unreal Project, bajo el directorio Source, crea un nuevo directorio llamado AppsflyerSteamModule.
-
Copia los siguientes archivos desde
appsflyer-unreal-epic-sample-app/AppsflyerEpicIntegrationFiles/AppsflyerEpicModule
a la nueva carpeta:- AppsflyerModule.cpp
- AppsflyerEpicModule.cpp
- AppsflyerEpicModule.h
- DeviceID.h
- RequestData.h
-
Genera archivos de proyecto con el fin de agregar OpenSSL. Aprender más
-
En el
GameMode.h
, agrega laStartPlay()
:
class AAppsFlyerSampleGameMode : public AGameModeBase
{
GENERATED_BODY()
public:
AAppsFlyerSampleGameMode();
virtual void StartPlay() override;
};
- Abre la carpeta
Source/AppsFlyerSample/AppsFlyerSampleGameMode.cpp
y agrega el siguiente include a tu archivo GameMode.cpp.
#include "AppsflyerEpicModule/AppsflyerEpicModule.cpp"
- Agrega la siguiente función, asegurándote de reemplazar el
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;
}
}
- Reporta los eventos in-app.
Actualizado hace 11 días