> **Premium Feature**
>
> This feature is a premium option that must be enabled on your account. If you would like to use this capability on your project, please [submit a support ticket](https://support.dolby.io/hc/en-au) or reach out to your [sales/solutions](https://optiview.dolby.com/contact/) contact.

# Tracking Viewers

With THEOlive, you can syndicate content through multiple distribution partners while utilizing the same channel, or alternatively track different groups through aliases. This can be helpful for aggregating viewing and billing data for a group of viewers.

Additionally, when using the advanced reporting feature, you might want to assign tracking metadata to individual viewers to post-process later in your data and BI analysis tools. This is all possible with our viewer tracking workflows.

## Tracking Workflow

The following is an **example workflow** for setting up stream tracking:

1. Create a THEOlive channel

2. Enable [*Token Security*](https://optiview.dolby.com/docs/theolive/v1/platform/security/token-based-security.md) on the channel or alias

3. When you create your self-signed token, add one or both of the following parameters to a `streaming` object in the `payload` of your JWT:

   * **trackingId**: Groups viewers of the same channel, allows you to get the aggregated bandwidth usage of all viewers. This is useful for billing a single channel or alias if you use multiple distribution partners and want aggregated billing metrics back or viewer reports for groups of viewers. The maximum size is 128 characters
   * **customViewerData** : Access the bandwidth consumption of each viewer for analytics purposes and passthrough metadata from your CMS for a viewer and be able to retrieve it in a viewer report. This data is not parsed by our system and can be a series of key-value pairs for you to extract later. The maximum size is 1024 characters

4. Pass the JWT through to the player as described in the [*Token Security*](https://optiview.dolby.com/docs/theolive/v1/platform/security/token-based-security.md) section

5. To get *Advanced Reports*, including user-reports, please contact your Dolby representative for access.

*Note: Either or both `trackingId` and/or `customViewerData` may be used depending on what kind of tracking you need to achieve.*

To put it all together, here is an example `payload` for a JWT that includes sample `trackingId` and `customViewerData`:

```json
{
  "streaming": {
    "tracking": {
      "trackingId": "groupAbc"
    },
    "customViewerData": "user=user123;appVersion=x.y.x",
    "tokenType": "Subscribe"
  },
  "iat": 1750813271,
  "exp": 1750813871 // required for the token to be valid
}
```

Here is the JWT that is used to generate this token, you can paste it into [jwt.io](https://jwt.io/#token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdHJlYW1pbmciOnsidHJhY2tpbmciOnsidHJhY2tpbmdJZCI6Imdyb3VwQWJjIn0sImN1c3RvbVZpZXdlckRhdGEiOiJ1c2VyPXVzZXIxMjM7YXBwVmVyc2lvbj14LnkueCIsInRva2VuVHlwZSI6IlN1YnNjcmliZSJ9LCJpYXQiOjE3NTA4MTMyNzEsImV4cCI6MTc1MDgxMzg3MX0.OvIZAvs6XL4KQ8YTtIdjdJNZ5oS6Jkosj3mq274gdrw).

```text
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdHJlYW1pbmciOnsidHJhY2tpbmciOnsidHJhY2tpbmdJZCI6Imdyb3VwQWJjIn0sImN1c3RvbVZpZXdlckRhdGEiOiJ1c2VyPXVzZXIxMjM7YXBwVmVyc2lvbj14LnkueCIsInRva2VuVHlwZSI6IlN1YnNjcmliZSJ9LCJpYXQiOjE3NTA4MTMyNzEsImV4cCI6MTc1MDgxMzg3MX0.OvIZAvs6XL4KQ8YTtIdjdJNZ5oS6Jkosj3mq274gdrw
```

To see the validation tool validate the token, insert the random secret used to sign the token: `d2e166fdda89824a6c493d8a2af7a0754199eff9e38c579cba8783767a44039c`.

### Notes

* Tracking can be used independently of secure channels. You can pass the same payload parameters in a JWT, however, we require that the token is "valid". This means that the required date fields *must* be valid or the token will be ignored. If a channel does not have token security enabled, however, be aware that anyone can view the channel with or without a jwt token. If secure channels are not enabled, the signature is not validated, so there is a risk that a user *could* change the values
* If you are combining our OptiView real-time (Millicast) streaming solution and our live streaming solution (THEOlive), you may use the *secret* from the Millicast subscriber token as the secret you provide to THEOlive and you can use the same JWTs across both streaming products
* `tokenType` should be set to `Subscribe`
