Unreal Steam

Link para o repositório
GitHub

Integração do SDK Unreal Steam da AppsFlyer

A AppsFlyer capacita os profissionais de marketing de jogos a tomar melhores decisões, fornecendo ferramentas poderosas para executar a atribuição entre plataformas.

A atribuição do jogo requer que o jogo integre o SDK da AppsFlyer que registra as primeiras aberturas, sessões consecutivas e eventos in-app. Por exemplo, eventos de compra.
Recomendamos que você use este aplicativo de amostra como referência para integrar o SDK da AppsFlyer ao seu jogo Unreal Steam. Observação: o código de amostra a seguir é atualmente suportado apenas em um ambiente Windows.


Prerequisites

  • Unreal Engine 4.2x
  • SDK do Steamworks integrado no seu UE4 (geralmente está incluído no UE4 de terceiros e não há necessidade de baixá-lo).
  • Cliente Steam instalado com um usuário ativo.

AppsflyerSteamModule - Interface

AppsflyerSteamModule.h, incluído na pasta appsflyer-unreal-steam-sample-app/AppsflyerSteamIntegrationFiles/AppsflyerSteamModule , contém o código e a lógica necessários para se conectar aos servidores da AppsFlyer e relatar eventos.

Init

Este método recebe sua chave de API e ID do aplicativo e inicializa o módulo da AppsFlyer.

Assinatura do método

void Init(const char* devkey, const char* appID)

Usage:

AppsflyerSteamModule()->Init(<< DEV_KEY >>, << STEAM_APP_ID>>);

Arguments:

Start

Este método envia as primeiras solicitações de abertura e /sessão para a AppsFlyer.

Assinatura do método

void Start(bool skipFirst = false)

Usage:

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

// with the flag
bool skipFirst = [SOME_CONDITION];
AppsflyerSteamModule()->Start(skipFirst);

LogEvent

Esse método recebe um nome de evento e um objeto JSON e envia eventos in-app para a AppsFlyer.

Assinatura do método

void LogEvent(std::string event_name, json event_parameters)

Usage:

//set event name
std::string event_name = "af_purchase";
//set json string
std::string event_parameters = "{\"af_currency\":\"USD\",\"af_price\":6.66,\"af_revenue\":24.12}";
AppsflyerSteamModule()->LogEvent(event_name, event_parameters);

GetAppsFlyerUID

Obter o ID do dispositivo exclusivo da AppsFlyer. O SDK gera um ID de dispositivo exclusivo da AppsFlyer na instalação do aplicativo. Quando o SDK é iniciado, esse ID é registrado como o ID da primeira instalação do aplicativo.

Assinatura do método

std::string GetAppsFlyerUID()

Usage:

AppsflyerSteamModule()->GetAppsFlyerUID();

IsInstallOlderThanDate

Este método recebe uma string de data e retorna true se a data de modificação da pasta do jogo for mais antiga que a string de data. O formato da string de data é: "2023-janeiro-01 23:12:34"

Assinatura do método

bool IsInstallOlderThanDate(std::string datestring)

Usage:

// 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");

// example usage with skipFirst -
// skipping if the install date is NOT older than the given date
bool isInstallOlderThanDate = AppsflyerSteamModule()->IsInstallOlderThanDate("2023-January-10 23:12:34");
AppsflyerSteamModule()->Start(!isInstallOlderThanDate);

Executando o aplicativo de exemplo

  1. Abra o motor UE4.
  2. Escolha Novo projeto > Jogos > Primeira pessoa.
  3. Escolha C++ (em vez de Blueprints).
  4. Dê um nome ao projeto AppsFlyerSample e clique em Criar projeto.
  5. Siga as instruções para implementar a AppsFlyer em seu jogo Steam.
  6. Inicie o aplicativo de amostra do editor do mecanismo UE4.
  7. Após 24 horas, o painel é atualizado e mostra instalações orgânicas e não orgânicas e eventos in-app.

Implementando a AppsFlyer em seu jogo Steam

Setup

  1. Certifique-se de que o Steam esteja em seus UE4 de terceiros. Saiba mais
  2. Adicione as seguintes definições a Config/DefaultEngine.ini. Para referência, consulte o 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. No seu editor Unreal, vá para Plugins, ative o Subsistema Online Steam e reinicie o editor.
  2. Abra o projeto em seu editor C++ preferido e em [YOUR-APP-NAME].Build.cs arquivo, adicione OpenSSL, OnlineSubsystem, e OnlineSubsystemSteam às suas dependências e HTTP como uma dependência privada:
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "OpenSSL", "OnlineSubsystem", "OnlineSubsystemSteam" });
PrivateDependencyModuleNames.Add("HTTP");
  1. Nos arquivos do Unreal Project, no diretório Source, crie um novo diretório chamado AppsflyerSteamModule.
  2. Copie os seguintes arquivos de appsflyer-unreal-steam-sample-app/AppsflyerSteamIntegrationFiles/AppsflyerSteamModule para a nova pasta:
  • AppsflyerModule.cpp
  • AppsflyerSteamModule.cpp
  • AppsflyerSteamModule.h
  • DeviceID.h
  • RequestData.h
  1. Gere arquivos de projeto para adicionar OpenSSL. Saiba mais.
  2. No GameMode.h arquivo, adicione o StartPlay() function:
UCLASS(minimalapi)
class AAppsFlyerSampleGameMode : public AGameModeBase
{
 GENERATED_BODY()

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

  1. Abra a pasta Source/AppsFlyerSample/AppsFlyerSampleGameMode.cpp arquivo e adicione o seguinte include ao seu GameMode.cpp file:
#include "AppsflyerSteamModule/AppsflyerSteamModule.cpp"
  1. Adicione a seguinte função, certificando-se de substituir DEV_KEY and STEAM_APP_ID in the funçãoinit com as informações do seu aplicativo:
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_parameters = "{\"af_currency\":\"USD\",\"af_price\":6.66,\"af_revenue\":24.12}";
  AppsflyerSteamModule()->LogEvent(event_name, event_parameters);
 }
}
  1. Inicialize e inicie a integração da AppsFlyer.
  2. Reporte os eventos in-app.

Adding SteamVR Support

Please use the following guide in order to integrate your steam game with MetaXR

Excluindo salvamentos na nuvem do Steam (redefinindo a atribuição)

  1. Desabilite a nuvem do Steam.
  2. Delete the local files and the appsflyer_info file:

Delete the