---
title: Roku Channel Monitoring Setup
description: >-
  Set up RUM monitoring for Roku channels to track user interactions,
  performance, and errors on TV streaming applications.
breadcrumbs: >-
  Docs > RUM & Session Replay > Application Monitoring > Roku Monitoring > Roku
  Channel Monitoring Setup
---

# Roku Channel Monitoring Setup

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site). ().
{% /alert %}

{% /callout %}

This page describes how to instrument your applications for [Real User Monitoring (RUM)](https://docs.datadoghq.com/real_user_monitoring/) with the Roku SDK. RUM includes Error Tracking by default, but if you have purchased Error Tracking as a standalone product, see the [Error Tracking setup guide](https://docs.datadoghq.com/error_tracking/frontend/mobile/roku/) for specific steps.

The Datadog Roku SDK supports BrightScript channels for Roku OS 10 and higher.

## Setup{% #setup %}

### Step 1 - Declare the SDK as a dependency{% #step-1--declare-the-sdk-as-a-dependency %}

#### Using ROPM (recommended){% #using-ropm--recommended %}

`ROPM` is a package manager for the Roku platform (based on NPM). If you're not already using `ROPM` in your Roku project, read their [Getting started guide](https://github.com/rokucommunity/ropm). Once your project is set up to use `ROPM`, you can use the following command to install the Datadog dependency:

```
ropm install datadog-roku
```

#### Setup manually{% #setup-manually %}

If your project does not use `ROPM`, install the library manually by downloading the [Roku SDK](https://github.com/DataDog/dd-sdk-roku) zip archive and unzipping it in your project's root folder.

Make sure you have a `roku_modules/datadogroku` subfolder in both the `components` and `source` folders of your project.

### Step 2 - Specify application details in the UI{% #step-2--specify-application-details-in-the-ui %}

1. Navigate to [**Digital Experience** > **Add an Application**](https://app.datadoghq.com/rum/application/create).
1. Select **Roku** as the application type and enter an application name to generate a unique Datadog application ID and client token.
1. To disable automatic user data collection for client IP or geolocation data, uncheck the boxes for those settings. For more information, see [Roku Data Collected](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/roku/data_collected).

{% alert level="info" %}
If you've purchased Error Tracking as a standalone product (without RUM), navigate to [**Error Tracking** > **Settings** > **Browser and Mobile** > **Add an Application**](https://app.datadoghq.com/error-tracking/settings/setup/client) instead.
{% /alert %}

To ensure the safety of your data, you must use a client token. If you use only [Datadog API keys](https://docs.datadoghq.com/account_management/api-app-keys/#api-keys) to configure the `dd-sdk-roku` library, they are exposed client-side in the Roku channel's BrightScript code.

For more information about setting up a client token, see the [Client Token documentation](https://docs.datadoghq.com/account_management/api-app-keys/#client-tokens).

### Step 3 - Initialize the library{% #step-3--initialize-the-library %}

In the initialization snippet, set an environment name. For more information, see [Using Tags](https://docs.datadoghq.com/getting_started/tagging/using_tags/#rum--session-replay).

```
sub RunUserInterface(args as dynamic)
    screen = CreateObject("roSGScreen")
    scene = screen.CreateScene("MyScene")
    screen.show()

    datadogroku_initialize({
        clientToken: "<CLIENT_TOKEN>",
        applicationId: "<APPLICATION_ID>"
        site: "",
        env: "<ENV_NAME>",
        sessionSampleRate: 100, ' the percentage (integer) of sessions to track
        launchArgs: args
    })

    ' complete your channel setup here
end sub
```

#### Sample session rates{% #sample-session-rates %}

To control the data your application sends to Datadog RUM, you can specify a sampling rate for RUM sessions while [initializing the RUM Roku SDK](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/roku/advanced_configuration/#enrich-user-sessions). The rate is a percentage between 0 and 100. By default, `sessionSamplingRate` is set to 100 (keep all sessions).

## Instrument the channel{% #instrument-the-channel %}

See **Track RUM Resources** to enable automatic tracking of all your resources, and **Enrich user sessions** to add custom global or user information to your events.

### Track Views{% #track-views %}

To split [user sessions](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/roku/data_collected) into logical steps, manually start a View using the following code. Every navigation to a new screen within your channel should correspond to a new View.

```
    viewName = "VideoDetails"
    viewUrl = "components/screens/VideoDetails.xml"
    m.global.datadogRumAgent.callfunc("startView", viewName, viewUrl)
```

### Track RUM Actions{% #track-rum-actions %}

RUM Actions represent the interactions your users have with your channel. You can forward actions to Datadog as follows:

```
    targetName = "playButton" ' the name of the SG Node the user interacted with
    actionType = "click" ' the type of interaction, should be one of "click", "back", or "custom" 
    m.global.datadogRumAgent.callfunc("addAction", { target: targetName, type: actionType})
```

### Track RUM errors{% #track-rum-errors %}

Whenever you perform an operation that might throw an exception, you can forward the error to Datadog as follows:

```
    try
        doSomethingThatMightThrowAnException()
    catch error
        m.global.datadogRumAgent.callfunc("addError", error)
    end try
```

## Sending data when device is offline{% #sending-data-when-device-is-offline %}

RUM ensures availability of data when your user device is offline. In case of low-network areas, or when the device battery is too low, all the RUM events are first stored on the local device in batches.

Each batch follows the intake specification. They are sent as soon as the network is available, and the battery is high enough to ensure the Datadog SDK does not impact the end user's experience. If the network is not available while your application is in the foreground, or if an upload of data fails, the batch is kept until it can be sent successfully.

This means that even if users open your application while offline, no data is lost. To ensure the SDK does not use too much disk space, the data on the disk is automatically discarded if it gets too old.

## Further reading{% #further-reading %}

- [RUM Roku Advanced Configuration](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/roku/advanced_configuration)
- [Source code for dd-sdk-roku](https://github.com/DataDog/dd-sdk-roku)
- [Explore Datadog RUM](https://docs.datadoghq.com/real_user_monitoring)
- [Monitor your Roku channels with Datadog RUM](https://www.datadoghq.com/blog/monitor-roku-with-rum/)
