Chapter length

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

The chapter length variable is the duration of the chapter, in seconds. Set it on every media.chapterStart event.

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

Set length 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 length in seconds as the third 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 length in seconds as the third 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

Set length 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 length 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 length as the third 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 length in seconds as the third argument (length) to ADBMobile.media.createChapterObject:

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

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

code language-json
{
  "playerTime": { "playhead": 0, "ts": 1699523820000 },
  "eventType": "chapterStart",
  "params": {
    "media.chapter.length": 240
  }
}

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

recommendation-more-help
media-analytics-help