Media Tracking

Prev Next

Media tracking captures audio and video playback in your iOS app — initialization, play, pause, position changes, and end of playback. Each event is tied to a page name and identifies the media item by name.

Method

Method

Description

trackMedia(_ event: MIMediaEvent)

Records a media playback event. Each event represents one state change for one media item on one page.

Build a media event

MIMediaEvent

Initialize with the page name and a populated MIMediaParameters. Optionally attach MIEventParameters, MISessionParameters, or MIEcommerceParameters.

MIMediaEvent(pageName: String, parameters: MIMediaParameters)

MIMediaParameters

Property

Description

name

Media item identifier (for example the video title or asset ID).

action

One of "init", "play", "pause", "stop", "pos", "seek", "eof".

position

Current playback position in seconds.

duration

Total duration of the media item in seconds.

bandwith

Optional bandwidth in kbps.

soundIsMuted

Optional NSNumber (boolean) indicating muted state.

soundVolume

Optional volume value (0.0–1.0).

customCategories

Dictionary of numbered custom media categories.

Example: track a play event

let mediaParams = MIMediaParameters(
    "intro-video",
    action: "play",
    position: 12,
    duration: 120
)

let mediaEvent = MIMediaEvent(pageName: "Onboarding", parameters: mediaParams)
MappIntelligence.shared()?.trackMedia(mediaEvent)
MIMediaParameters *mediaParams = [[MIMediaParameters alloc]
    initWith:@"intro-video"
      action:@"play"
    position:@12
    duration:@120];

MIMediaEvent *mediaEvent = [[MIMediaEvent alloc]
    initWithPageName:@"Onboarding"
          parameters:mediaParams];

[[MappIntelligence shared] trackMedia:mediaEvent];
  • Send "init" when the player loads the media item.

  • Send "play" on play and "pause" on pause.

  • Send "pos" at a regular interval (for example every 30 seconds) while the media is playing.

  • Send "seek" when the user scrubs the timeline.

  • Send "eof" when playback completes.

The SDK throttles repeated init events for the same media name and action — different episodes can therefore safely send "init" in rapid succession (this behavior was tightened in version 5.1.1).

Related: Object Oriented Tracking, Pages.