Datazoom is a high-availability real-time data collection solution. This document summarizes how to integrate the Roku player with the Datazoom platform.
Login to Datazoom here: https://app.datazoom.io
Add a Collector as indicated here: How to add a Collector
Copy the
config key
that was created at the end of the process
Click the icon indicated below to copy the Configuration Key
4. Replace the <configuration id from Datazoom>
with the Key you copied above.
5. Replace the <url given by Datazoom>
with <
https://platform.datazoom.io/>
Adding dependencies to your project
Roku Plugin for Eclipse IDE
For Roku plugin installation and usage in Eclipse IDE
https://sdkdocs.roku.com/display/sdkdoc/Roku+Plugin+for+Eclipse+IDE
Installation Instructions
Clone the latest version of the repository:
git clone https://gitlab.com/datazoom/roku/dz_collector_roku_release.git
Extract the components folder from latest version of the cloned repository
Copy the components folder in your channel project.
We assume that:
The developer had already created a Roku project (in Eclipse IDE).
The project does not have a components folder. If there is already a components folder, then copy the content of the components directory(DzLib folder) into your project's components directory.
eg: /<your project>/components/DzLibThis project contains the base and native-collector library (inside DzLib folder).
Configuring collector library in channel
Copy the following in MainScene.brs (in components folder) or in the brs file you intend to configure the collector library.
In Sub/function init(), add the following
m.player = m.top.findNode("<Player ID>") m.DzLib = m.top.findNode("DzLib") DzCollector()
Once the collector is successfully instantiated we can set desired console log level for the collector instance:
m.DzLib.callFunc("setLogLevel","info")
Valid log levels are: "off", "error", "warning", "info", "debug", or "verbose"
Default log level is set to “warning”
Also add the following function for initializing SDK
Sub DzCollector() m.DzLib.libConfiguration = { configURL : "<url given by Datazoom>", configId: "<configuration id from Datazoom>" } m.DzLib.initiateCollector = true End Sub
DzCollector() will call the above function when initialized.
IMPORTANT!
To confirm Datazoom SDK is successfully initialized and can be safely attached to player and start collecting data or fire custom events you MUST use following callback:
m.DzLib.observeField("connectionSuccess", "datazoomSDKInitialized")
or check following field:
m.DzLib.connectionSuccess '(true/false)
Change the configURL, configId, and <Player ID> as per the requirement.
Copy the following inside <children> in MainScene.xml or in the xml file you intend to configure the collector library.
<DzLib id="DzLib" />
At this point the Datazoom SDK is initialized. We can send Custom Events, Custom Metadata, user data, device data and geo location data.
Custom Events and Custom Metadata
We can set Custom Metadata for the Datazoom SDK independently for the app session and/or for player. Custom Metadata that is set for app session will be available during entire app session if not changed or removed. Custom Metadata that is set for player will be reset with each new player session.
To set Custom Metadata for app session we use following method:
m.DzLib.callFunc("setDZSessionMeta","DataZoom SESSION Metadata Key", "DataZoom SESSION Metadata Value") or m.DzLib.callFunc("setDZSessionMeta","AnotherCustomSESSIONMetaKey","AnotherCustomSESSIONMetaValue") or m.DzLib.callFunc("setDZSessionMeta",{customMetaKeyDict1 : "CustomSESSIONMetaValueDict1", customMetaKeyDict2 : "CustomSESSIONMetaValueDict2", customMetaKeyDictNth : "CustomSESSIONMetaValueDictNth" })
To set Custom Metadata for player session we use following method:
m.DzLib.callFunc("setDZPlayerMeta","DataZoom PLAYER Metadata Key", "DataZoom PLAYER Metadata Value") or m.DzLib.callFunc("setDZPlayerMeta","AnotherPLAYERCustomMetaKey","AnotherPLAYERCustomMetaValue") or m.DzLib.callFunc("setDZplayerMeta",{customMetaKeyDict1 : "CustomPLAYERMetaValueDict1", customMetaKeyDict2 : "CustomPLAYERMetaValueDict2", customMetaKeyDictNth : "CustomPLAYERMetaValueDictNth" })
Change "CustomMetaKey" and "CustomMetaValue" to any text or variable you want to send to collector service
To read Custom Metadata that are set using previous methods we use following methods:
For session Custom Metadata:
customSessionMeta = m.DzLib.callFunc("getDZSessionMeta")
For player Custom Metadata:
customSessionMeta = m.DzLib.callFunc("getDZPlayerMeta")
We delete Custom Metadata that are set for session and player by using this methods:
For session Custom Metadata:
m.DzLib.callFunc("rmDZSessionMeta")
For player Custom Metadata:
m.DzLib.callFunc("rmDZPlayerMeta")
Also, we can send Custom Events to the Datazoom SDK using following methods:
m.DzLib.callFunc("generateDatazoomEvent","SOME CUSTOM EVENT")
We can also add Custom Metadata to generated Custom Event. Metadata sent using this method will be sent with the custom event only.
m.DzLib.callFunc("generateDatazoomEvent", "SOME CUSTOM EVENT", {customEventMetaKeyDict1 : "CustomEventMetaValueDict1", customEvemtMetaKeyDict2 : "CustomEventMetaValueDict2", customEventMetaKeyDictNth : "CustomEventMetaValueDictNth"})
Now, after we create player instance we can add player to Datazoom SDK
Add the following inside <children> in MainScene.xml or in the xml file you intend to configure the collector library.
<Video id="<Player ID>" />
and your xml file should look like this:
<children> <DzLib id="DzLib" /> <Video id="<Player ID>" /> </children>
Change <Player ID> as per the requirement.
Now add the following function for initializing player to Datazoom SDK:
Sub DzPlayer() m.DzLib.playerInit = { player: m.video } m.DzLib.initiatePlayer = true End Sub
DzPlayer() will call the above function when initialized.
Optionally, m.DzLib.playerInit
can include a noContentObserver
field which, if set to true
, will prevent the collector from observing the video node’s content metadata for the purpose of creating content sessions automatically. This may be useful for apps who prefer to manage content sessions explicitly through the setting of m.DzLib.initiatePlayer
. The following demonstrates such a use case:
Sub DzPlayer() m.DzLib.playerInit = { player: m.video, noContentObserver: true } m.DzLib.initiatePlayer = true End Sub
At this point Datazoom SDK is fully initialized with player. Selected data points will be collected from player and sent to collector service.
Roku RAF
If Roku RAF is enabled and implemented in your app please use following method to pass CTX object to DZ SDK:
m.DzLib.callFunc("generateAdEvent",adCtx)
You can download Datazoom Roku DEMO app which demonstrates above methods from here :
git clone https://gitlab.com/datazoom/roku/roku-native-demo.git
Follow instructions in provided Readme.md file for importing demo project to Eclipse.
Instructions to create a compiled zip file
Your-Project(Right click) > Export > BrightScript > BrightScript Deployment >[Change File name/path, if needed (.zip)] > Finish
Open browser and go to Roku's local network IP address.(eg: 192.168.0.9). Provide username and password of developer mode.
Click upload and select the newly created zip file. Click install.
The channel will automatically start playing. This channel can also be played by-> go to Roku menu, select the Roku developer channel and play.
To view the data points generated by Roku, go to Linux terminal and type
telnet <Roku's Local IP> 8085
eg: - telnet 192.168.0.9 8085
Comments
0 comments
Article is closed for comments.