This page covers data collection for the Closed captioning player state. See Streams impacted by closed captioning, Closed captioning counts, and Closed captioning total duration for the corresponding reporting metrics.
The closed captioning player state tracks when the viewer turns captions on and off. Fire a state-start event when captions are enabled and a state-end event when captions are disabled. The backend computes three metrics from these events: streams impacted, count of state entries, and total time in state.
a.media.states.closedcaptioning.set, a.media.states.closedcaptioning.count, a.media.states.closedcaptioning.timemediaCollection.statesStart[] and mediaCollection.statesEnd[] (entries with name: "closedCaptioning")c_contextdata.a.media.states.closedcaptioning.set, c_contextdata.a.media.states.closedcaptioning.count, c_contextdata.a.media.states.closedcaptioning.timeWeb SDK
Use sendEvent to send a media.statesUpdate event with the state added to statesStart:
alloy("sendEvent", {
xdm: {
eventType: "media.statesUpdate",
mediaCollection: {
statesStart: [{ name: "closedCaptioning" }],
sessionID: "{sid}",
playhead: 60
}
}
});
When the viewer disables captions, send another event with the state in statesEnd:
alloy("sendEvent", {
xdm: {
eventType: "media.statesUpdate",
mediaCollection: {
statesEnd: [{ name: "closedCaptioning" }],
sessionID: "{sid}",
playhead: 90
}
}
});
Mobile SDK
Use tracker.trackPlayerStateStart() and tracker.trackPlayerStateEnd() with the MediaConstants.PlayerState.CLOSED_CAPTION constant.
iOS (Swift)
let stateObject = Media.createStateObjectWith(stateName: MediaConstants.PlayerState.CLOSED_CAPTION)
tracker.trackPlayerStateStart(info: stateObject)
tracker.trackPlayerStateEnd(info: stateObject)
Android (Kotlin)
val stateObject = Media.createStateObject(MediaConstants.PlayerState.CLOSED_CAPTION)
tracker.trackPlayerStateStart(stateObject)
tracker.trackPlayerStateEnd(stateObject)
Roku (BrightScript)
Use sendMediaEvent to send a media.statesUpdate event with the state added to statesStart:
m.aepSdk.sendMediaEvent({
"xdm": {
"eventType": "media.statesUpdate",
"mediaCollection": {
"statesStart": [{ "name": "closedCaptioning" }],
"playhead": 60
}
}
})
When the viewer disables captions, send another event with the state in statesEnd:
m.aepSdk.sendMediaEvent({
"xdm": {
"eventType": "media.statesUpdate",
"mediaCollection": {
"statesEnd": [{ "name": "closedCaptioning" }],
"playhead": 90
}
}
})
Media Edge API
Call the statesUpdate endpoint with closedCaptioning in statesStart (or statesEnd when the viewer disables captions):
{
"events": [{
"xdm": {
"eventType": "media.statesUpdate",
"mediaCollection": {
"statesStart": [{ "name": "closedCaptioning" }],
"sessionID": "{sid}",
"playhead": 60
}
}
}]
}
Media SDK
Use ADB.Media.createStateObject and the ADB.Media.PlayerState.ClosedCaptioning constant:
var stateObject = ADB.Media.createStateObject(ADB.Media.PlayerState.ClosedCaptioning);
tracker.trackPlayerStateStart(stateObject);
tracker.trackPlayerStateEnd(stateObject);
Media Collection API
Send a stateStart POST request when captions are enabled, and a stateEnd POST when they are disabled:
{
"playerTime": { "playhead": 60, "ts": 1699523820000 },
"eventType": "stateStart",
"params": {
"media.state.name": "closedCaptioning"
}
}
See the Media Collection API events reference for the full request structure.