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
xdm.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 xdm.mediaCollection.chapterDetails when calling sendEvent:

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

Pass the chapter position as the second argument to createChapterObject.

code language-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

Pass the chapter position as the second argument to createChapterObject.

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

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

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

code language-brightscript
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 xdm.mediaCollection.chapterDetails:

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

Legacy implementation types (Analytics-only)

Media SDK JS 3.x

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

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

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

Pass the chapter position as the second argument to ADBMobile.media.createChapterObject:

code language-javascript
var chapterInfo = ADBMobile.media.createChapterObject(
  "Pilot Episode - Opening",  // name
  1,                          // position
  240,                        // length
  0                           // startTime
);
ADBMobile.media.trackEvent(ADBMobile.media.Event.ChapterStart, chapterInfo, null);
Roku 2.x

Pass the chapter position as the second argument (position) to adb_media_init_chapterinfo:

code language-brightscript
adb = ADBMobile()
chapterInfo = adb_media_init_chapterinfo("Pilot Episode - Opening", 1, 240.0, 0.0)  ' name, position, length, startTime

adb.mediaTrackEvent(adb.MEDIA_CHAPTER_START, chapterInfo)
Media Collection API

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

code language-json
{
  "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