MediaTracker

Tracks events based on interactions with media content. Engagement with content is tracked based on the time spent consuming the content and what percentage of the content is consumed if the content has a finite duration.

Upon stopping the content a completion event will be sent.

The MediaTracker is an EventTracker and can track custom events which will be associated with the current media content.

The media tracker tracks an initial view event on creation and starts in a paused state. Engagement will not be tracked until play is called.

For media content of an unknown length use the MediaTracker.UNKNOWN_DURATION constant as the duration.

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class PageProperties @JvmOverloads constructor(val title: String? = null, val url: Uri? = null, val referrer: Uri? = null) : PermutiveParams

Properties describing the page hosting the video (if relevant)

Link copied to clipboard
class VideoProperties @JvmOverloads constructor(val title: String? = null, val genre: List<String>? = null, val contentType: List<String>? = null, val country: String? = null, runtimeSec: Int? = null, val ageRating: String? = null, val originalLanguage: String? = null, val audioLanguage: String? = null, val areSubtitlesEnabled: Boolean? = null, val subtitlesLanguage: String? = null, val seasonNumber: Int? = null, val episodeNumber: Int? = null, val consecutiveEpisodes: Int? = null, val iabCategories: List<String>? = null) : PermutiveParams

Standard properties on all video events. All properties are optional.

Functions

Link copied to clipboard
abstract fun pause()

Called when the content is paused. Engagement tracking will be stopped.

Link copied to clipboard
abstract fun play(position: Long? = null)

Called when content is playing or the position has been changed by the user. Engagement tracking will be started.

Link copied to clipboard
abstract fun setDuration(duration: Long)

Set the duration in milliseconds of the content. This needs to be set before the video is stopped to be reflected in the completion event.

Link copied to clipboard
abstract fun stop()

Called when user has stopped engaging with the content such as closing the content. This will send the media completion event.

Link copied to clipboard
abstract fun track(eventName: String)

Tracks an event with no properties.

abstract fun track(eventName: String, properties: EventProperties?)

Tracks an event with optional properties.

Link copied to clipboard
abstract fun trackAdView(durationMs: Long, adProperties: AdTracker.AdProperties?): AdTracker

Tracks an ad view and returns an AdTracker. The initial ad view event and all other ad events tracked with the ad tracker will share the view ID of the events tracked through this MediaTracker instance.

Link copied to clipboard
abstract fun trackWithMediaProperties(eventName: String)

Tracks a custom event with the media properties attached. MediaTracker.VideoProperties for video tracking.

abstract fun trackWithMediaProperties(eventName: String, eventProperties: EventProperties?)

Tracks a custom event with the media properties attached and optional custom properties. MediaTracker.VideoProperties for video tracking.