Episode

This page covers data collection for the Episode variable. See Episode for the corresponding reporting dimension.

The episode variable is the episode number within the season (typically a string integer like "13"). Pair with Show and Season so engagement can be broken out by individual episode.

Property
Value
Context data variable
a.media.episode
XDM collection field
xdm.mediaCollection.sessionDetails.episode
Audience Manager trait
c_contextdata.a.media.episode
Required
No
Sent with
Session start, session close
Web SDK

Set episode inside xdm.mediaCollection.sessionDetails when calling sendEvent:

code language-javascript
alloy("sendEvent", {
  xdm: {
    eventType: "media.sessionStart",
    mediaCollection: {
      sessionDetails: {
        episode: "13"
      },
      playhead: 0
    }
  }
});
iOS

Pass the episode number as a metadata key in the HashMap argument to trackSessionStart. Use MediaConstants.VideoMetadataKeys.EPISODE.

code language-swift
var metadata: [String: String] = [:]
metadata[MediaConstants.VideoMetadataKeys.EPISODE] = "13"

tracker.trackSessionStart(info: mediaObject, metadata: metadata)
Android

Pass the episode number as a metadata key in the HashMap argument to trackSessionStart. Use MediaConstants.VideoMetadataKeys.EPISODE.

code language-kotlin
val metadata = HashMap<String, String>()
metadata[MediaConstants.VideoMetadataKeys.EPISODE] = "13"

tracker.trackSessionStart(mediaInfo, metadata)
Roku

Use createMediaSession to set episode inside sessionDetails:

code language-brightscript
m.aepSdk.createMediaSession({
    "xdm": {
        "eventType": "media.sessionStart",
        "mediaCollection": {
            "sessionDetails": {
                "episode": "13"
            },
            "playhead": 0
        }
    }
})
Media Edge API

Call the sessionStart endpoint with episode inside xdm.mediaCollection.sessionDetails:

code language-json
{
  "events": [{
    "xdm": {
      "eventType": "media.sessionStart",
      "mediaCollection": {
        "sessionDetails": {
          "name": "video-123",
          "length": 128,
          "contentType": "vod",
          "playerName": "HTML5 Player",
          "channel": "Sports",
          "episode": "13"
        },
        "playhead": 0
      }
    }
  }]
}

Legacy implementation types (Analytics-only)

Media SDK JS 3.x

Pass the episode in the contextData object using ADB.Media.VideoMetadataKeys.Episode:

code language-javascript
var contextData = {};
contextData[ADB.Media.VideoMetadataKeys.Episode] = "13";

tracker.trackSessionStart(mediaInfo, contextData);
Chromecast

Use ADBMobile.media.VideoMetadataKeys.EPISODE to set the episode number in the StandardMediaMetadata property of the media object before calling trackSessionStart:

code language-javascript
var mediaInfo = ADBMobile.media.createMediaObject("My Video", "video-123", 128,
  ADBMobile.media.StreamType.VOD, ADBMobile.media.MediaType.Video);
var standardMetadata = {};
standardMetadata[ADBMobile.media.VideoMetadataKeys.EPISODE] = "13";
mediaInfo[ADBMobile.media.MediaObjectKey.StandardMediaMetadata] = standardMetadata;
ADBMobile.media.trackSessionStart(mediaInfo, null);
Media Collection API

Include media.episode in the params object:

code language-json
{
  "playerTime": { "playhead": 0, "ts": 1699523820000 },
  "eventType": "sessionStart",
  "params": {
    "media.episode": "13"
  }
}

See the Media Collection API sessions reference for the full request structure.

recommendation-more-help
media-analytics-help