Application collectors
Roku Native Media Player
For the Roku Collector
The Roku Native Media Player Extension is a configuration option for the Roku Collector by Datazoom that makes the following additional data points automatically collectable in real time.
Integration Instructions
Prerequisites
We assume that:
- The developer had already created a Roku project.
- Only one instance of the library is created (Singleton)
- The project has a
componentsfolder. If there is none - it should be created in the same folder where thesourcefolder andmanifestfile for the channel are. m.globalis set and accessible from everywhere:
1m.global = screen.GetGlobalNode()2m.global.id = "GLOBAL_NODE"3' https://developer.roku.com/en-gb/docs/references/brightscript/interfaces/ifsgscreen.md#getglobalnode-as-rosgnode1. Preparatory Steps
Clone the latest version of the repository:
git clone https://gitlab.com/datazoom/roku/collector-release.git
Copy the datazoom folder into your channel components folder.
eg: /
2. Create the DataZoom Library After Render Thread Initialization
Copy the following in MainScene.brs or in the brs file you intend to configure the collector library. In sub init(), add the following
1datazoom = CreateObject("roSGNode", "DataZoom")2datazoom.callFunc("setLogLevel", "info")3datazoom.callFunc("setup", "...ADD_CONFIG_KEY_HERE...")45m.global.AddField("datazoom", "node", false)6m.global.datazoom = datazoomNOTE: Events are sent only after datazoom.callFunc("setup", ...) succeeds.
3. Hook Up the Video Node to Start Generating Events
1m.datazoom = m.global.datazoom2m.datazoom.callFunc("setupVideoObservers", m.videoPlayer)IMPORTANT!
A reference to the Video Node is stored when setupVideoObservers is called.
To avoid memory leaks and ensure the content session ends properly, always call videoClosed when the video player is closed.
1m.datazoom.callFunc("videoClosed")4. Forward RAF Events to Generate Ad-Related Events
1raf = Roku_Ads()2raf.setTrackingCallback(_rafCallback, m.global.datazoom)34sub _rafCallback(datazoom, eventType, ctx)5 datazoom.rafEvent = ctx6end sub5. Logging
Once the collector is successfully instantiated we can set desired console log level for the collector instance. Valid log levels are: "off", "error", "warning", "info", "debug", or "verbose" Default log level is set to “warning”
6. Custom Events and Metadata
To send a custom event, call the generateEvent method with the event name as the first parameter.
This will send an event with the type/name Custom_AppLaunched, with whatever metadata is enabled in the dashboard.
NOTE: Calling this before setup will result in no events being sent, and a warning being logged.
1m.datazoom.callFunc("generateEvent", "AppLaunched")There are three ways to pass custom metadata to the event:
- Calling
setGlobalMetadataorappendGlobalMetadataon anyDatazoomnode. This data will be included in all events sent from anyDatazoomnode.
1m.datazoom.callFunc("setGlobalMetadata", { "key": "value" })- Calling
setMetadataorappendMetadata. This will add metadata only to this specific node/context and it overwrites the values set "globally".
1m.datazoom.callFunc("setMetadata", { "key": "value" })- The third argument of the
generateEventmethod. This will add metadata only to this specific event and it overwrites the values set "globally" and "locally".
1m.datazoom.callFunc("generateEvent", "AppLaunched", { "key": "value" })NOTE: To avoid name collisions, metadata set with the above methods will be appended under a custom key/node.
1{2 "device": {},3 "geo_location": {},4 ...5 "custom": {6 "key": "value"7 }8}Overwriting metadata defined in the dashboard is not supported for now.
Data Storage Notes
- The library is designed to be instantiated only once (singleton pattern).
- Configs are cached and do not change after setup.
- All data is sourced from Video player fields and Ad RAF events
- Derived context
- Calling videoClosed destroys most data, except for some session-level metadata.
- The session is closed after the timeout defined in: app_session_timeout_mins
Ad Frameworks Extensions
If your Roku application has a media player with an ad framework, Datazoom’s Roku Collector with a Roku Native Media Player can be extended with the following ad framework extensions.
Supported Data Points
Events
Discrete occurrences driven by user interactions or system actions
Metadata
Attributes
User
Fluxdata
Metrics measuring changing parameters over time
-
Audio Track
-
Buffer Duration (Content Session)
-
Buffer Start Recency (Content Session)
-
Content Buffer Duration (Content Session)
-
Content Buffer Start Recency (Content Session)
-
Content Error Count (App Session)
-
Content Media Request Count (App Session)
-
Content Media Request Recency (Content Session)
-
Content Milestone Recency (Content Session)
-
Content Pause Duration (Content Session)
-
Content Playback Duration (Content Session)
-
Content Playback Start Count (App Session)
-
Content Playback Start Recency (Content Session)
-
Content Session Start Timestamp
-
Content Stall Count (Content Session)
-
Content Stall Start Recency (Content Session)
-
Error Count (App Session)
-
Heartbeat Recency (Content Session)
-
Pause Duration (Content Session)
-
Pause Recency (Content Session)
-
Playback Duration (Content Session)
-
Player State
-
Player Viewable
-
Player Viewable Percent
-
Playhead Position
-
Rendition Audio Bitrate
-
Rendition Change Recency (Content Session)
-
Rendition Height
-
Rendition Name
-
Rendition Video Bitrate
-
Rendition Width
-
Seek Start Recency (Content Session)
-
Stall Count (Content Session)
-
Stall Start Recency (Content Session)
- Subtitle Track