Unity Steam
Link para o repositório
GitHub
Integração do SDK Unity 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 Unity Steam.
Prerequisites
- Motor do Unity.
- SDK do Steamworks integrado ao seu projeto Unity.
- Cliente Steam instalado com um usuário ativo. Observação: ele deve estar em execução para teste.
AppsflyerSteamModule - Interface
AppsflyerSteamModule.cs
, incluído na pasta de cenas, contém o código e a lógica necessários para se conectar aos servidores da AppsFlyer e relatar eventos.
AppsflyerSteamModule
This method receives your API key, Steam app ID, the parent MonoBehaviour and a sandbox mode flag (optional, false by default) and initializes the AppsFlyer Module.
Assinatura do método
AppsflyerSteamModule(
string DEV_KEY,
string STEAM_APP_ID,
MonoBehaviour mono,
bool isSandbox = false,
bool collectSteamUid = true
)
Usage:
// for regular init
AppsflyerSteamModule afm = new AppsflyerSteamModule(DEV_KEY, STEAM_APP_ID, this);
// for init in sandbox mode (reports the events to the sandbox endpoint)
AppsflyerSteamModule afm = new AppsflyerSteamModule(DEV_KEY, STEAM_APP_ID, this, true);
// for init without reporting steam_uid
AppsflyerSteamModule afm = new AppsflyerSteamModule(DEV_KEY, STEAM_APP_ID, this, false, false);
Argumentos
string DEV_KEY
: obtenha do profissional de marketing ou do QG da AppsFlyer.string STEAM_APP_ID
: encontrado no SteamDB.MonoBehaviour mono
:bool isSandbox
: Whether to activate sandbox mode. False by default.bool collectSteamUid
: Whether to collect Steam UID or not. True by default.
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
afm.Start();
// with the flag
bool skipFirst = [SOME_CONDITION];
afm.Start(skipFirst);
Stop
Once this method is invoked, our SDK no longer communicates with our servers and stops functioning.
Useful when implementing user opt-in/opt-out.
Assinatura do método
void Stop()
Usage:
// Starting the SDK
afm.Start();
// ...
// Stopping the SDK, preventing further communication with AppsFlyer
afm.Stop();
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(string event_name, Dictionary<string, object> event_parameters)
Usage:
// set event name
string event_name = "af_purchase";
// set event values
Dictionary<string, object> event_parameters = new Dictionary<string, object>();
event_parameters.Add("af_currency", "USD");
event_parameters.Add("af_price", 6.66);
event_parameters.Add("af_revenue", 12.12);
// send logEvent request
afm.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
string GetAppsFlyerUID()
Usage:
AppsflyerSteamModule afm = new AppsflyerSteamModule(DEV_KEY, STEAM_APP_ID, this);
afm.Start();
string af_uid = afm.GetAppsFlyerUID();
SetCustomerUserId
Setting your own customer ID enables you to cross-reference your own unique ID with AppsFlyer’s unique ID and other devices’ IDs.
This ID is available in raw-data reports and in the Postback APIs for cross-referencing with your internal IDs.
Can be used only before calling Start()
.
Assinatura do método
void SetCustomerUserId(string cuid)
Usage:
AppsflyerSteamModule afm = new AppsflyerSteamModule(DEV_KEY, STEAM_APP_ID, this);
afm.SetCustomerUserId("15667737-366d-4994-ac8b-653fe6b2be4a");
afm.Start();
IsInstallOlderThanDate
This method receives a date string and returns true if the game folder creation date is older than the date string. The date string format is: "2023-03-13T10:00:00+00:00"
Assinatura do método
bool IsInstallOlderThanDate(string datestring)
Usage:
// the creation date in this example is "2023-03-23T08:30:00+00:00"
bool newerDate = afm.IsInstallOlderThanDate("2023-06-13T10:00:00+00:00");
bool olderDate = afm.IsInstallOlderThanDate("2023-02-11T10:00:00+00:00");
// will return true
Debug.Log("newerDate:" + (newerDate ? "true" : "false"));
// will return false
Debug.Log("olderDate:" + (olderDate ? "true" : "false"));
// example usage with skipFirst -
// skipping if the install date is NOT older than the given date
bool IsInstallOlderThanDate = afm.IsInstallOlderThanDate("2023-02-11T10:00:00+00:00");
afm.Start(!IsInstallOlderThanDate);
Executando o aplicativo de exemplo
- Abra o hub do Unity e abra o projeto.
- Adicione o Steamworks ao seu projeto do Unity. Siga as instruções do SDK do Steamworks e adicione-o através do seu gerenciador de pacotes.
- Use o código de exemplo em
SteamScript.cs
e atualize-o com o seuDEV_KEY
andAPP_ID
. - Adicione o
SteamManager
andSteamScript
para um objeto de jogo vazio (ou use o da pasta de cenas).
- Inicie o aplicativo de amostra por meio do editor do Unity e verifique se o log de depuração mostra a seguinte mensagem:
- 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
- Adicione o Steamworks ao seu projeto do Unity. Siga as instruções do SDK do Steamworks e adicione-o através do seu gerenciador de pacotes.
- Add
SteamManager.cs
a um objeto de jogo. - Adicione o script de
Assets/Scenes/AppsflyerSteamModule.cs
ao seu aplicativo. - Use o código de exemplo em
Assets/Scenes/SteamScript.cs
e atualize-o com o seuDEV_KEY
andAPP_ID
. - Inicialize o SDK.
AppsflyerSteamModule afm = new AppsflyerSteamModule(DEV_KEY, STEAM_APP_ID, this);
- Inicie a integração da AppsFlyer.
- Reporte os eventos in-app.
Excluindo salvamentos na nuvem do Steam (redefinindo a atribuição)
- Desative a nuvem do Steam.
- Exclua os arquivos locais.
- Delete the PlayerPrefs data the registry/preferences folder, or use PlayerPrefs.DeleteAll() when testing the attribution in the UnityEditor.
Atualizado 18 dias atrás