Collecting data with Trackers and Webhooks

  1. Home
  2. Docs
  3. Collecting data with Trackers and Webhooks
  4. Trackers – collecting data from your own applications
  5. Roku Tracker
  6. Getting started

Getting started

Designing how and what to track in your app is an important decision. Check out our docs about tracking design here.

The following steps will guide you through setting up the Roku tracker in your project and tracking a simple event.

Installation

There are two options to install the Roku tracker package to your project:

  1. using Roku package manager (ropm),
  2. by manually copying package files.

Using Roku Package Manager (ropm)

ropm is a package manager for the Roku platform. If you are using ropm in your project, you may install the Roku tracker using the following command:

ropm install snowplow@npm:@snowplow/roku-tracker

Manual Installation

The Roku tracker may be installed by simply copying source files to your Roku project. You may download and unpack the dist.zip or dist.tar.gz package from the latest release build on Github. Copy the following folders and files to your Roku project:

  1. Contents of dist/source into your source directory
  2. Contents of dist/components into your components directory

Implementation

It 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")
Code language: PHP (php)

If you installed the package manually, mount the component as follows:

m.global.AddField("snowplow", "node", false) m.global.snowplow = CreateObject("roSGNode", "Snowplow")
Code language: PHP (php)

Initialization

Trackers are initialized by setting the init property with configuration of the tracker. This configuration takes the form of a roAssociativeArray. At its most basic, the configuration takes a Snowplow collector endpoint like so:

m.global.snowplow.init = { network: { collector: "http://..." } }
Code language: PHP (php)

To learn more about configuring how events are sent, check out this page.

Tracking events

To track an event, simply assign its properties as a roAssociativeArray to a field corresponding to the event type. For instance, to track a structured event, assign the structured property:

m.global.snowplow.structured = { se_ca: "category", se_ac: "action", se_la: "label", se_pr: "property", se_va: 10 }
Code language: PHP (php)

Visit documentation about tracking events to learn about other supported event types. You may also want to read about adding more data to tracked events.

Testing

Testing that your event tracking is properly configured can be as important as testing the other aspects of your app. It confirms that you are generating the events you expect.

We provide two types of pipeline for testing and debugging. Snowplow Mini is especially useful in manual schema and pipeline testing. Snowplow Micro is a minimal pipeline designed to be used as part of your app’s automated test suite.

Check out the example Roku channel to see the tracker used with a Snowplow Micro.

If you’d like to learn more about Snowplow BDP you can book a demo with our team, or if you’d prefer, you can try Snowplow technology for yourself quickly and easily.