Snowplow is a scalable open-source platform for rich, high quality, low-latency data collection. It is designed to collect high quality, complete behavioral data for enterprise business.
To find out more, please check out the Snowplow website and our documentation.
The Snowplow Roku Tracker allows you to add analytics to your Roku apps when using a Snowplow pipeline.
With this tracker you can collect granular event-level data as your users interact with your Roku applications.
Technical documentation can be found for each tracker in our Documentation.
Install the package using ropm in your project:
ropm install snowplow@npm:@snowplow/roku-tracker
dist.zip
or dist.tar.gz
package from the latest release build on Github.dist/source
into your source
directorydist/components
into your components
directoryIt is recommended that you instantiate Snowplow and add it to the global scope.
In this way, it will be accessible from anywhere within your SceneGraph application.
You may create the instance in the init
function of your main scene.
If you installed the package using ropm, mount the component as follows:
m.global.AddField("snowplow", "node", false)
m.global.snowplow = CreateObject("roSGNode", "snowplow_Snowplow")
If you installed the package manually, mount the component as follows:
m.global.AddField("snowplow", "node", false)
m.global.snowplow = CreateObject("roSGNode", "Snowplow")
Trackers are initialized by setting the init
property with configuration of the tracker.
Below is an example configuration, please refer to the documentation for a complete specification.
m.global.snowplow.init = {
namespace: "ns1", ' optional, defaults to "default"
network: {
collector: "https://...",
method: "POST",
retryCount: 3 ' optional, defaults to 0
},
subject: {
domainUserId: "",
networkUserId: "",
appId: ""
}
}
You may initialize multiple trackers with different namespaces.
Setting the init
property with the same tracker namespace updates the configuration of the tracker.
When no namespace is given, a namespace with the name "default" is used (both in configuration and when tracking events).
To track events, simply assign their properties as associative arrays to fields corresponding to event types.
Events will be sent to all initialized trackers (with any namespace) when setting the event types on the Snowplow instance.
To send events to a specific tracker, call its namespace as follows: m.global.snowplow.trackerNamespace.structured = {...}
.
The following are some examples of the tracked events.
Please refer to the documentation for specificiation of event properties.
' Tracking a screen view event using all initialized trackers
m.global.snowplow.screenView = {
id: CreateObject("roDeviceInfo").GetRandomUUID(),
name: "HomeScene",
type: "scene",
transitionType: "init"
}
' Tracking a screen view event using a tracker with the namespace "ns1"
m.global.snowplow.ns1.screenView = {
id: CreateObject("roDeviceInfo").GetRandomUUID(),
name: "HomeScene",
type: "scene",
transitionType: "init"
}
' Tracking a self-describing events
m.global.snowplow.selfDescribing = {
data: {
id: CreateObject("roDeviceInfo").GetRandomUUID(),
name: "name",
type: "type"
},
schema: "iglu:com.snowplowanalytics.mobile/screen_view/jsonschema/1-0-0"
}
' Tracking a structured event
m.global.snowplow.structured = {
namespace: "otherNamespace",
se_ca: "category",
se_ac: "action",
se_la: "label",
se_pr: "property",
se_va: 10
}
' Adding context to an event
m.global.snowplow.structured = {
...
context: [
{
data: {
id: CreateObject("roDeviceInfo").GetRandomUUID(),
name: "contextName",
type: "type"
},
schema: "iglu:com.snowplowanalytics.mobile/screen_view/jsonschema/1-0-0"
}
]
}
To enable video tracking for a Video node, assign a roAssociativeArray
with the video node to the enableVideoTracking
property:
m.global.snowplow.enableVideoTracking = {
video: m.Video
}
Technical Docs | Setup Guide |
---|---|
Technical Docs | Setup Guide |
Contributing |
---|
Contributing |
Assuming git, Node.js 12 LTS or 16 LTS are installed.
The tracker is implemented using BrighterScript.
git clone https://github.com/snowplow-incubator/snowplow-roku-tracker.git
To build the package in order to include it in other Roku projects:
npm install
on the projectnpm i ropm -g
ropm install
npm run build
dist
folder and may be copied for use in another Roku projectThe tracker comes with a demo app that shows it in use. It is a simple video player with a fixed collection of played videos and an interface to switch between them.
The project is located in the src-demo-app
subfolder.
The following steps assume that you have enabled developer mode on your Roku device and it is connected to your network.
Run npm install
on the project
Install ropm npm i ropm -g
Install ropm packages ropm install
Create .env
file with environment variables in the root of this repository
ROKU_IP=192.168.100.129
ROKU_PASSWORD=XXXX
Add configuration for Snowplow collector to src-demo-app/manifest
snowplow_collector=http://192.168.100.127:9090
snowplow_method=POST
Start the demo app using npm run demo-app
Alternatively, you may run the demo app from Visual Studio Code as the debug configuration is already prepared. Install the BrightScript extension to Visual Studio Code and choose "Run demo app" in the debug options.
Events will be sent to the Snowplow collector as you navigate through the app.
The tracker functionality is verified using unit and integration tests. Unit tests test individual components of the tracker in isolation and do not make any external network requests. Integration tests use a Snowplow Micro instance to verify end-to-end tracking of events.
The tests are located in the tests
subfolder.
The following steps assume that you have enabled developer mode on your Roku device and it is connected to your network.
Run npm install
on the project
Install ropm npm i ropm -g
Install ropm packages ropm install
Create .env
file with environment variables in the root of this repository
ROKU_IP=192.168.100.129
ROKU_PASSWORD=XXXX
Start Snowplow Micro on your computer
Add configuration for your Snowplow Micro (with the network IP of your computer) instance to tests/manifest
snowplow_collector=http://192.168.100.127:9090
snowplow_method=POST
Run the tests using npm test
Alternatively, you may run the tests from Visual Studio Code as the debug configuration is already prepared. Install the BrightScript extension to Visual Studio Code and choose "Run tests" in the debug options.
The Snowplow Roku Tracker is copyright 2021 Snowplow Analytics Ltd.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.