Ссылка на репозиторий
GitHub

Интеграция SDK AppsFlyer в Roku

AppsFlyer позволяет маркетологам игровых приложений принимать оптимальные решения, предоставляя высокоэффективные инструменты для решения проблем, таких как кросс-платформенная атрибуция, мобильная и веб-аналитика, диплинкинг, обнаружение мошенничества, контроль и защита конфиденциальности и многое другое.

Для атрибуции игры игра должна обмениваться данными с API AppsFlyer по протоколу HTTPS и сообщать об активностях пользователя, например первом открытии, последовательных сессиях и внутренних событиях приложения. Например, события покупки.
Мы рекомендуем использовать этот пример приложения в качестве справки по интеграции AppsFlyer в ваш канал Roku.


AppsFlyerRokuSDK — интерфейс

AppsFlyerRokuSDK.brs в папке source/appsflyer-integration-files содержит необходимый код и логику для подключения к серверам AppsFlyer и передачи отчетов по событиям.

Init

Данный метод получает ваш ключ API и идентификатор приложения и инициализирует модуль AppsFlyer, который передает AppsFlyer запросы о первом открытии и сессиях.

Сигнатура метода

AppsFlyer().init(<< DEV_KEY >>, << APP_ID >>)

Usage:

' Initialize the AppsFlyer integration (send first-open/session event)
AppsFlyer().init(<< DEV_KEY >>, << APP_ID >>)

Arguments:

  • APP_ID: находится в ifAppInfo.
  • DEV_KEY: получите у маркетолога или AppsFlyer HQ.

NOTE: It is recommended to set the APP_ID manually.

When retrieving the APP_ID с GetID() roAppInfo, the channel ID is "dev" if the application is sideloaded, and then app will not be able to communicate with the AppsFlyer endpoint.

Start

Данный метод передает запросы «first open/session» в AppsFlyer.

Сигнатура метода

start()

Usage:

AppsFlyer().start()

Stop

This method stops the SDK from functioning and communicating with AppsFlyer servers. It's used when implementing user opt-in/opt-out.

Сигнатура метода

stop()

Usage:

' Starting the SDK
AppsFlyer().start()
' ...
' Stopping the SDK, preventing further communication with AppsFlyer
AppsFlyer().stop()

LogEvent

Этот метод получает имя события и объект JSON и отправляет внутренние события приложения в AppsFlyer.

Сигнатура метода

logEvent: function(eventName as string, eventParameters as object, eventCustomParameters = {})

Usage:

' logEvent without eventCustomParameters
trackEventParameters = { "af_revenue": 24.22, "af_currency": "ILS" }
AppsFlyer().logEvent("af_purchase", trackEventParameters)

' logEvent with eventCustomParameters
trackEventParameters = { "af_revenue": 24.22, "af_currency": "ILS", "freeHandParam": "freeHandValue" }
trackCustomEventParameters = { "freeHandParam": "freeHandValue" }
AppsFlyer().logEvent("af_purchase", trackEventParameters, trackCustomEventParameters)

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.

Сигнатура метода

setCustomerUserId(string cuid)

Usage:

AppsFlyer().init(devkey, appid)
AppsFlyer().setCustomerUserId("")
AppsFlyer().start()

Запуск примера приложения

  1. Откройте папку appsflyer-sample-app в VSCode.
  2. In source/main.brsзамените следующие параметры собственными:
devkey = << DEV_KEY >>
appid = << APP_ID >>
  1. Deploy the channel: - by (using this plugin makes it easier), - by zipping the content of the source folder
    Zipped source
    and then deploying it to Roku through Roku's Development Application Installer:
    Zipped source

  2. After the app loads, you may use the following commands through the Roku remote:

    • Click the down button to set customer user id (cuid) to "AF roku test CUID".
    • Click the right button to set customer user id (cuid) to "" (reset it).
    • Click the up button to stop the SDK.
    • Click the left button to send the start (first open/session) event.
    • Click the options button (*) to send logEvent.
    • Click the replay button (*) to send logEvent with custom parameters.
    • Click the OK button after every command in order to refresh the logs.

Внедрение AppsFlyer в ваш канал Roku

Setup

  1. Скопируйте файлы из папки appsflyer-integration-files в свой проект.
  2. Добавьте следующий код в свой файл main.brs и инициализируйте интеграцию AppsFlyer:
Function Main(args as Dynamic) as Void
    ...
    showAppsflyerChannelSGScreen(args)
    ...
End Function

sub showAppsflyerChannelSGScreen(args as Dynamic)
    screen = CreateObject("roSGScreen")
    m.port = CreateObject("roMessagePort")
    screen.setMessagePort(m.port)
    scene = screen.CreateScene("AppsFlyerScene")
    screen.show()

    ' Initialize the AppsFlyer integration
    AppsFlyer().init(DEV_KEY, APP_ID)
    ' Enable debugging if necessary
    AppsFlyer().enableDebugLogs(true) ' same as AppsFlyer().setLogLevel("debug")

    ' ConversionData response arrives here
    while true
        msg = Wait(0, m.port)
        ?"MESSAGE RECEIVED: "msg.GetData()
        msgType = Type(msg)
        if msgType = "roSGScreenEvent"
            if msg.isScreenClosed() then
                return
            end if
        end if
    end while
end sub
  1. Start the SDK.
  2. Подайте отчет о внутренних событиях приложения.