Analytics Roku Collector
How to setup the Roku Collector
Bitmovin Analytics enables you to get useful insights into the video usage in your apps. Our Roku Collector offers a simple integration with our Bitmovin Player and the native Roku Player.
In order to follow along this guide you need at least a basic setup of your chosen Player. If you haven't set up your Player yet go to the corresponding Player documentation pages: Bitmovin Player getting started guide, Roku documentation.
For Roku collector when adding your domain to the allow-list in the Bitmovin dashboard, the domain is your channel id and it must be postfixed with .roku
. During local development the domain is defined as dev.roku
.
Step 1: Add Collector Folders to you project
Go to the Github Repository of the Bitmovin Analytics Roku Collector and download the whole project to your machine.
If you are using our Bitmovin Player, copy the collectorCore
and the bitmovinPlayerCollector
folders into the components folder of your Roku app.
If you are using Native Roku Player, copy the collectorCore
and the nativePlayerCollector
folders into the components folder of your Roku app.
Step 2: Setup the collector
Initialise Collector
First create a Bitmovin Analytics configuration object. Replace INSERT_LICENSE_KEY_HERE
with your analytics license key. You can further customise it by adding optional configuration parameters. For more information and a complete list of configuration fields see our Configuration Guide Configuration Guide.
# Create a Bitmovin Analytics Configuration object by using your Bitmovin analytics license key
analyticsConfig = {
key: "INSERT_LICENSE_KEY_HERE",
title: "Your Video Title",
videoId: "your-video-id",
}
Or configure the license key in the manifest
file located in the root folder of the project.
# Analytics license key
bitmovin_analytics_license_key=INSERT_LICENSE_KEY_HERE
Then create a collector object. To start monitoring the player, call the initializeAnalytics
function with the analytics configuration object, and then the initializePlayer
function with your player object as an argument.
For Bitmovin Player this must happen before the setup function is called on the player.
For Roku Player this must happen before any content is set on the player.
# Create a Bitmovin Player Collector Object
m.bitmovinPlayerCollector = CreateObject("roSgNode", "bitmovinPlayerCollector")
# initialize Analytics and the Player
m.bitmovinPlayerCollector.callFunc("initializeAnalytics", analyticsConfig)
m.bitmovinPlayerCollector.callFunc("initializePlayer", m.bitmovinPlayer)
# Create a Native Roku Player Collector Object
m.nativePlayerCollector = CreateObject("roSgNode", "nativePlayerCollector")
# initialize Analytics and the Player
m.nativePlayerCollector.callFunc("initializeAnalytics", analyticsConfig)
m.nativePlayerCollector.callFunc("initializePlayer", m.nativePlayer)
Video source changes
When switching to a new video we recommend that you follow the sequence of events below.
# adapt analytics configuration object
analyticsConfig = {
title: "new video title",
videoId: "new video id",
}
# change the source of the player
m.bitmovinPlayer.callFunc(m.bitmovinFunctions.LOAD, <newSource>)
# notify collector of source change
m.bitmovinPlayerCollector.callfunc("setAnalyticsConfig", analyticsConfig)
# adapt analytics configuration object
analyticsConfig = {
title: "new video title",
videoId: "new video id",
}
# change the source of the player
m.nativePlayer.content = <newSource>
# notify collector of source change
m.nativePlayerCollector.callfunc("setAnalyticsConfig", analyticsConfig)
Clean up the collector
For Native Roku Player clean up the analytics collector when it is no longer needed before removing the native video element.
# Clean up analytics collector before removing the native roku player
m.nativePlayerCollector.callFunc("destroy", invalid)
Step 3: Check Statistics in Dashboard
After the setup is done there is nothing more to do. Events are recorded automatically and you can head over to the analytics dashboard to see statistics.
Examples
You can find fully functional code examples in our Github Repository.
Updated about 1 year ago