Monitor Roku
Add FastPix video analytics to any Roku SceneGraph channel with the Data Core SDK: drop-in installation, a three-step tracker integration, view-level QoE metrics, and beacons that are wire-compatible with the FastPix Web SDK.
This guide explains how to add FastPix video analytics to a Roku channel. It walks you through installation, a minimal three-step integration, the complete configuration reference, and troubleshooting.
Before you begin
Make sure you have the following:
- A Roku device with Developer Mode enabled.
- A SceneGraph channel project that includes a
manifest, asource/directory, and acomponents/directory. - A FastPix workspace ID. The SDK uses this value as the beacon subdomain.
- Roku OS 9.1 or later.
How the SDK works
The FastPix Data Core SDK observes a SceneGraph Video node and translates Roku state transitions into FastPix events. As playback proceeds, the SDK accumulates view-level quality-of-experience (QoE) metrics such as watch time, rebuffer count, rebuffer duration, rebuffer percentage, seek count, time to first frame, throughput, and scaling ratio and sends them as compact JSON beacons to a FastPix collector.
The SDK is wire-compatible with the FastPix Web SDK, so the same backend ingests data from both. You don’t need to make any backend changes.
Add the SDK files to your channel
The SDK ships as BrightScript source files. There is no Roku package manager, so you copy two directory trees directly into your channel.
To install the SDK, copy the fastpix folders from the SDK into your channel’s source/ and components/ directories:
After you copy the files, your channel structure looks like this:
That completes the installation. You don’t need to vendor anything else.
Important: Copy every file under
source/fastpix/andcomponents/fastpix/. A missing file prevents the component from loading and causes a compile error when you sideload.
Integrate the tracker
After you install the SDK, complete the following three steps to start tracking playback.
Declare the tracker in your scene XML
In the scene component that owns your Video node, add a <FastPixTracker> element as a sibling of the Video node. Replace YOUR_WORKSPACE_ID with your FastPix workspace key.
Wire the Video node in your scene’s init()
Tell the tracker which Video node to observe. Set the video field before you start the tracker.
Set metadata and start tracking before play
Set the per-video metadata, start the tracker, and then start playback. Start the tracker before you play the video so that the playerReady and viewBegin events fire before the first frame.
After you complete these steps, the SDK emits beacons to https://YOUR_WORKSPACE_ID.anlytix.io for every state change, plus a heartbeat every 10 seconds during steady playback.
FastPixTracker interface reference
The <FastPixTracker> component exposes input fields that you set from your channel and output fields that you can observe. Every field is optional unless it’s marked as required.
Input fields
These fields pass data from your channel to the SDK.
Output fields
You can observe these fields to monitor the SDK from your channel.
Use the output fields to build an in-app debug overlay or to detect persistent transport failures:
Metadata schema
Set the m.fp.data associative array before you set m.fp.control to "start". The keys in the following tables are the ones that the FastPix dashboard recognizes. The SDK passes through any other keys that you add, which is useful for custom attributes.
Identity
Player
Stream
Custom attributes
Auto-populated fields
The SDK sets the following fields automatically. Don’t set them yourself.
Lifecycle patterns
The way you manage the tracker depends on whether you play a single video, a playlist, or swap content within a single tracker.
Play a single video and then exit
Start the tracker and player, and then stop both when playback ends. Setting control to "stop" flushes the final viewCompleted beacon.
Play a playlist
For each new video, stop the tracker, set the new metadata, and restart the tracker.
Swap content within a single tracker
To load a new video into the same tracker, for example, when you move from one episode to the next in the same UI fire a videoChange event with the dispatch field.
When you fire a videoChange event, the SDK closes the previous view by sending a viewCompleted beacon, creates a new view_id, and starts a fresh view. You don’t need to stop and restart the tracker.
Fire custom events
To fire a custom event, set m.fp.dispatch to { name: "<eventName>", data: { ... } }. The following events are available to fire from your channel.
Note: Don’t fire playback events such as
play,playing, orbufferingdirectly. The SDK derives these events fromVideo.stateautomatically.
Emitted events reference
The SDK emits the following events, which appear as event_name=... in each beacon body. A full state event carries the complete view state, and a delta event carries only changed fields.
Verify the integration
After you integrate the SDK, verify that beacons reach your workspace by using the dashboard, the telnet debug console, or in-app observers.
Check the FastPix dashboard
- Sideload your channel and play a video for about 30 seconds.
- Open the real-time view in your FastPix workspace dashboard.
Within about 15 seconds of the first beacon, the view appears with a Playing status. As the view progresses, the dashboard updates with real metrics.
Use the telnet debug console
Set debug="true" on the tracker, and then connect to the BrightScript console:
With debugging enabled, the console prints output similar to the following:
Use in-app observers
Observe the lastBeaconStatus and lastBeaconError fields on the tracker to build an in-app debug overlay. This approach is useful in shipped builds where telnet isn’t available. For an example, see Output fields.
Troubleshoot common issues
Complete example
Drop the following three files into a fresh Roku channel, alongside the SDK trees that you copied in the install step, to create a working integration.
source/main.brs:
components/MyPlayerScene.xml:
components/MyPlayerScene.brs:
For a complete reference channel that includes a picker, playback, and a debug overlay, see samples/host-channel/ in the SDK repository.
Advanced configuration
Use the following patterns to extend your integration.
- Multiple players per scene: Instantiate one
<FastPixTracker>perVideonode. Trackers don’t share state. - A/B testing: Vary the
experiment_namevalue inm.fp.dataper session. - Custom dimensions: Any unknown key that you add to
m.fp.datarides every beacon. Usecustom_1throughcustom_10for dimensions that you want the FastPix dashboard to surface as filterable. - Final flush: The
viewCompletedbeacon is sent through the Task thread when you setm.fp.control = "stop". The tracker keeps the Task alive long enough for the beacon to land, so you don’t need to wait. - Registry usage: The SDK uses one
roRegistrySectionnamedFastPix. Its footprint is less than 300 bytes.
Get support
To diagnose issues, set debug="true" on the tracker and watch the console with telnet <roku-ip> 8085 while you test. The lastBeaconStatus and lastBeaconError output fields surface the most recent HTTP result for in-app monitoring.