|
| 1 | +--- |
| 2 | +title: "Media tracking (v2)" |
| 3 | +date: "2025-03-21" |
| 4 | +--- |
| 5 | + |
| 6 | +```mdx-code-block |
| 7 | +import Media from "@site/docs/reusable/media/_index.md" |
| 8 | +``` |
| 9 | + |
| 10 | +Media tracking has [multiple versions](/docs/sources/trackers/javascript-trackers/web-tracker/tracking-events/media/index.md) of schema available. |
| 11 | +This document is for version 2 of the schemas; tracker versions earlier than v0.3.0 [only support v1 tracking](/docs/sources/trackers/roku-tracker/media-tracking/v1/index.md). |
| 12 | + |
| 13 | + |
| 14 | +## Configuration |
| 15 | + |
| 16 | +Most tracking of [Audio](https://developer.roku.com/en-au/docs/references/scenegraph/media-playback-nodes/audio.md) and [Video](https://developer.roku.com/en-au/docs/references/scenegraph/media-playback-nodes/video.md) nodes is automatic, so configuration is minimal. |
| 17 | + |
| 18 | +For backwards compatibility with [v1 media tracking](/docs/sources/trackers/roku-tracker/media-tracking/v1/index.md), most options will accept either `roAssociativeArray` format in the `enableMediaTracking` call as long as `version` is specified as `2`. |
| 19 | + |
| 20 | +The accepted options include: |
| 21 | + |
| 22 | +| Attribute | Type | Description | Required? | |
| 23 | +| --- | --- | --- | --- | |
| 24 | +| `media` / `audio` / `video` | Audio / Video | Audio/Video node to be tracked | yes | |
| 25 | +| `version` | Integer | Tracking schema version to use; should be set to 2 | yes | |
| 26 | +| `id` | UUID | A unique ID to use for the media `session` entity to group all tracked events | no; generated by tracker if not provided | |
| 27 | +| `label` / `options.label` | String | An identifiable custom label sent with the event in the `media_player` entity | no | |
| 28 | +| `sessions` | boolean | Whether to attach the media `session` entity on tracked events | no; defaults to `true` | |
| 29 | +| `pings` | boolean | Whether to periodically generate media `ping_event`s while content is playing | no; defaults to `true` | |
| 30 | +| `pingInterval` / `options.positionInterval` | Integer | Interval in seconds in which `ping_event`s should be reported | no, defaults to `30` seconds | |
| 31 | +| `boundaries` / `options.boundaries` | Integer[] | Percentage boundaries in playback for which `percentage_progress_event`s will be sent | no, defaults to `[25, 50, 75]` | |
| 32 | +| `captureEvents` / `options.captureEvents` | String[] | Types of events to capture. If specified, the event names should not have the `_event` suffix | no, defaults to all events | |
| 33 | +| `context` / `entities` | SelfDescribingJSON[] | Array of custom entities to include with all generated events | no | |
| 34 | + |
| 35 | +## Migrating from v1 |
| 36 | + |
| 37 | +If you are migrating from the v1 tracking, v2 has compatibility options to make the change easier. |
| 38 | + |
| 39 | +For backwards compatibility with the earlier tracking API, you can use `enableVideoTracking` instead of `enableMediaTracking`, and pass the node via the `video` option instead of `media`. |
| 40 | +For symmetry, `enableAudioTracking` and `audio` will work as well; the tracking will work with any combination of these method and option names regardless of node type, as long as `version: 2` is specified. |
| 41 | +You can also specifically opt into version 1 by passing `version: 1`. |
| 42 | + |
| 43 | +The additional options differ by version; but version 2 will accept the options from version 1 if it can't find the newer equivalent settings. |
| 44 | + |
| 45 | +| v2 Attribute | v1 Fallback | Type | Description | |
| 46 | +| --- | --- | --- | --- | |
| 47 | +| `media` / `audio` / `video` | `media` / `audio` / `video` | Audio / Video | Audio/Video node to be tracked | |
| 48 | +| `version` | `version` | Integer | Tracking schema version to use; should be set to 2 | |
| 49 | +| `id` | N/A | UUID | A unique ID to use for the media `session` entity to group all tracked events | |
| 50 | +| `label` | `options.label` | String | An identifiable custom label sent with the event in the `media_player` entity | |
| 51 | +| `sessions` | Default enabled | boolean | Whether to attach the media `session` entity on tracked events | |
| 52 | +| `pings` | Default enabled | boolean | Whether to periodically generate media `ping_event`s while content is playing | |
| 53 | +| `pingInterval` | `options.positionInterval` | Integer | Interval in seconds in which `ping_event`s should be reported | |
| 54 | +| `boundaries` | `options.boundaries` | Integer[] | Percentage boundaries in playback for which `percentage_progress_event`s will be sent | |
| 55 | +| `captureEvents` | `options.captureEvents` | String[] | Types of events to capture. If specified, the event names should not have the `_event` suffix | |
| 56 | +| `context` / `entities` | `context` | SelfDescribingJSON[] | Array of custom entities to include with all generated events | |
| 57 | + |
| 58 | + |
| 59 | +## Media Player Events |
| 60 | + |
| 61 | +```mdx-code-block |
| 62 | +<Media tracker="roku" /> |
| 63 | +``` |
0 commit comments