Picture in picture

This page covers data collection for the Picture in picture player state. See Streams impacted by picture in picture, Picture in picture counts, and Picture in picture total duration for the corresponding reporting metrics.

The picture in picture player state tracks when the viewer enters and exits picture-in-picture playback. Fire a state-start event when picture-in-picture begins and a state-end event when it ends. The backend computes three metrics from these events: streams impacted, count of state entries, and total time in state.

Property
Value
Context data variables
a.media.states.pictureinpicture.set, a.media.states.pictureinpicture.count, a.media.states.pictureinpicture.time
XDM collection field
mediaCollection.statesStart[] and mediaCollection.statesEnd[] (entries with name: "pictureInPicture")
Audience Manager traits
c_contextdata.a.media.states.pictureinpicture.set, c_contextdata.a.media.states.pictureinpicture.count, c_contextdata.a.media.states.pictureinpicture.time
Required
No
Sent with
State start, state end

Web SDK

Use sendEvent to send a media.statesUpdate event with the state added to statesStart:

alloy("sendEvent", {
  xdm: {
    eventType: "media.statesUpdate",
    mediaCollection: {
      statesStart: [{ name: "pictureInPicture" }],
      sessionID: "{sid}",
      playhead: 60
    }
  }
});

When the viewer exits picture-in-picture, send another event with the state in statesEnd:

alloy("sendEvent", {
  xdm: {
    eventType: "media.statesUpdate",
    mediaCollection: {
      statesEnd: [{ name: "pictureInPicture" }],
      sessionID: "{sid}",
      playhead: 90
    }
  }
});

Mobile SDK

Use tracker.trackPlayerStateStart() and tracker.trackPlayerStateEnd() with the MediaConstants.PlayerState.PICTURE_IN_PICTURE constant.

iOS (Swift)

let stateObject = Media.createStateObjectWith(stateName: MediaConstants.PlayerState.PICTURE_IN_PICTURE)

tracker.trackPlayerStateStart(info: stateObject)
tracker.trackPlayerStateEnd(info: stateObject)

Android (Kotlin)

val stateObject = Media.createStateObject(MediaConstants.PlayerState.PICTURE_IN_PICTURE)

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": "pictureInPicture" }],
            "playhead": 60
        }
    }
})

When the viewer exits picture-in-picture, send another event with the state in statesEnd:

m.aepSdk.sendMediaEvent({
    "xdm": {
        "eventType": "media.statesUpdate",
        "mediaCollection": {
            "statesEnd": [{ "name": "pictureInPicture" }],
            "playhead": 90
        }
    }
})

Media Edge API

Call the statesUpdate endpoint with pictureInPicture in statesStart (or statesEnd when the viewer exits PiP):

{
  "events": [{
    "xdm": {
      "eventType": "media.statesUpdate",
      "mediaCollection": {
        "statesStart": [{ "name": "pictureInPicture" }],
        "sessionID": "{sid}",
        "playhead": 60
      }
    }
  }]
}

Media SDK

Use ADB.Media.createStateObject and the ADB.Media.PlayerState.PictureInPicture constant:

var stateObject = ADB.Media.createStateObject(ADB.Media.PlayerState.PictureInPicture);

tracker.trackPlayerStateStart(stateObject);
tracker.trackPlayerStateEnd(stateObject);

Media Collection API

Send a stateStart POST request when picture-in-picture begins, and a stateEnd POST when it ends:

{
  "playerTime": { "playhead": 60, "ts": 1699523820000 },
  "eventType": "stateStart",
  "params": {
    "media.state.name": "pictureInPicture"
  }
}

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

recommendation-more-help
media-analytics-help