Roku (BrightScript)
AppsFlyer Roku SDK integration
AppsFlyerは、クロスプラットフォームアトリビューション、モバイルおよびウェブ分析、ディープリンク、不正検出、プライバシー管理と保全など、実際のペインポイントを解決する強力なツールを提供することで、ゲームマーケティング担当者がより良い意思決定を行えるように支援します。
ゲームのアトリビューションには、ゲームがHTTPSでAppsFlyerのAPIと通信し、初回起動、連続セッション、アプリ内イベントなどのユーザーアクティビティをレポートすることが必要です。(例:購入など)
AppsFlyer SDKをRoku channelに組み込む際の参考として、このサンプルアプリを使用することをお勧めします。
AppsFlyerRokuSDK - Interface
AppsFlyerRokuSDK.brs
, included in the source/appsflyer-integration-files
folder, contains the required code and logic to connect to AppsFlyer servers and report events.
Init
このメソッドは、APIキーとアプリIDを受け取り、AppsFlyerに初回起動とセッションのリクエストを送信するAppsFlyer Moduleを初期化します。
メソッドのシグネチャ
AppsFlyer().init(<< DEV_KEY >>, << APP_ID >>)
例:
' Initialize the AppsFlyer integration (send first-open/session event)
AppsFlyer().init(<< DEV_KEY >>, << APP_ID >>)
Arguments:
APP_ID
: Found via ifAppInfo.DEV_KEY
: Get from the marketer or AppsFlyer HQ.
NOTE: It is recommended to set the
APP_ID
manually.When retrieving the
APP_ID
withGetID()
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
このメソッドは、AppsFlyerに初回起動とセッションのリクエストを送信します。
メソッドのシグネチャ
start()
例:
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()
例:
' 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 = {})
例:
' 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)
例:
AppsFlyer().init(devkey, appid)
AppsFlyer().setCustomerUserId("")
AppsFlyer().start()
サンプルアプリの実行
- Open the
appsflyer-sample-app
folder in VSCode. - In
source/main.brs
, replace the following parameters with your own:
devkey = << DEV_KEY >>
appid = << APP_ID >>
-
Deploy the channel: - by (using this plugin makes it easier), - by zipping the content of the
source
folder
and then deploying it to Roku through Roku's Development Application Installer:
-
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.
- Click the down button to set customer user id (cuid) to
Implementing AppsFlyer in your Roku channel
Setup
- Copy the files from the
appsflyer-integration-files
folder into your project. - Add the following code to your
main.brs
file and Initialize the AppsFlyer integration:
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
- Start the SDK.
- Report in-app events.
更新済 7か月前