Chapter position

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

The chapter position variable is the index of the chapter inside the content, starting at 1 (typical) or 0 (depending on your convention). Use a stable index per chapter so that the same chapter rolls up across sessions.

Property
Value
Context data variable
a.media.chapter.position
XDM collection field
mediaCollection.chapterDetails.index
Audience Manager trait
c_contextdata.a.media.chapter.position
Required
No (Mobile SDK); Yes (Edge, Media Collection API)
Sent with
Chapter start, chapter close

Web SDK

Set index inside mediaCollection.chapterDetails when calling sendEvent:

alloy("sendEvent", {
  xdm: {
    eventType: "media.chapterStart",
    mediaCollection: {
      chapterDetails: {
        friendlyName: "Pilot Episode - Opening",
        index: 1,
        offset: 0,
        length: 240
      },
      sessionID: "{sid}",
      playhead: 0
    }
  }
});

Mobile SDK

Pass the chapter position as the second argument to createChapterObject.

iOS (Swift)

let chapterObject = Media.createChapterObjectWith(name: "Pilot Episode - Opening",
                                              position: 1,
                                                length: 240,
                                             startTime: 0)

tracker.trackEvent(event: MediaEvent.ChapterStart, info: chapterObject, metadata: nil)

Android (Kotlin)

val chapterObject = Media.createChapterObject("Pilot Episode - Opening",
                                              1L,
                                              240.0,
                                              0.0)

tracker.trackEvent(Media.Event.ChapterStart, chapterObject, null)

Roku (BrightScript)

Set index inside mediaCollection.chapterDetails when calling sendMediaEvent for media.chapterStart:

m.aepSdk.sendMediaEvent({
    "xdm": {
        "eventType": "media.chapterStart",
        "mediaCollection": {
            "chapterDetails": {
                "friendlyName": "Pilot Episode - Opening",
                "index": 1,
                "offset": 0,
                "length": 240
            },
            "playhead": 0
        }
    }
})

Media Edge API

Call the chapterStart endpoint with index inside mediaCollection.chapterDetails:

{
  "events": [{
    "xdm": {
      "eventType": "media.chapterStart",
      "mediaCollection": {
        "chapterDetails": {
          "index": 1,
          "offset": 0,
          "length": 240
        },
        "sessionID": "{sid}",
        "playhead": 0
      }
    }
  }]
}

Media SDK

Pass the chapter position as the second argument to ADB.Media.createChapterObject:

var chapterInfo = ADB.Media.createChapterObject(
  "Pilot Episode - Opening",
  1,
  240,
  0
);

tracker.trackEvent(ADB.Media.Event.ChapterStart, chapterInfo, contextData);

Media Collection API

Include media.chapter.index in the params object of your chapterStart POST request:

{
  "playerTime": { "playhead": 0, "ts": 1699523820000 },
  "eventType": "chapterStart",
  "params": {
    "media.chapter.index": 1
  }
}

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

recommendation-more-help
media-analytics-help