AV Insights

  • iOS
  • watchOS
  • tvOS
 

Foreword

In order to benefit from AV Insights you should first activate the feature. If you want to activate it please contact our support centre.

The AV Insights plugin allows the collection of events related to media consumption on your site. You will be able to follow the different interactions on your players and measure the performance of your content.

 

Media manipulation

 

Media instanciation

In order to be able to manipulate a media and measure its events, it is necessary to declare an object of type AVMedia :

let tracker = ATInternet.sharedInstance.defaultTracker
/// Property
/// let myMedia = tracker.avInsights.media
let myMedia = tracker.avInsights.Media(heartbeat: 5, bufferHeartbeat: 5)

Two parameters are available, in order to activate the automatic heartbeats. The first one enables playback tracking heartbeats and the second one enables buffering tracking heartbeats. The values provided are no longer used, the heartbeat evolution steps are now defined by us. The presence of the values will only activate the functionality.

The “heartbeat” is a refresh interval that changes automatically during playback.

 

Session ID management

An optional third parameter sessionId is available since Tracker version 2.19.0 to override the common standard property av_session_id present in each event generated by AV Insights tags. Please note that this parameter should be used only in special cases when you need to transfer sessions between different device.
The parameter is automatically generated by the Tracker for all standard cases.

let tracker = ATInternet.sharedInstance.defaultTracker
let myMedia = tracker.avInsights.Media(heartbeat: 5, bufferHeartbeat: 5, sessionId: "custom_session_id")

A property sessionId can be used to retrieve the value of the parameter:

sessionId() ⇒ String

Retrieve the session ID.

Example

let sessionID = myMedia.sessionId // "custom_session_id" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx"
 

Media properties

Some rules must be observed regarding the format of the properties used for the configuration of a media :

  • The syntax of the basic properties allowing to characterize a media must be respected (possible presence of underscore _ characters; see the exhaustive list of properties at the bottom of the page).
  • The $ symbol is a reserved symbol that must not be used in the name of a property.
  • The duration of the media or the positions of the playback head must be expressed in milliseconds.

The plugin provides a series of useful functions for the management of Media properties:

 

set

set(key: String, value: Any)

Declare a media property.

ParamTypeDescription
keyStringMedia property key
valueAnyMedia property value

Example

_ = myMedia.set(key: "av_content", value: "my_video")
_ = myMedia.set(key: "av_content_id", value: 12345)
 

get

get(key: String) ⇒  Any?

Retrieve a media property.

ParamTypeDescription
keyStringMedia property key

Example

let contentId = myMedia.get(key: "av_content_id") // 12345
 

del

del(key: String)

Delete a media property.

ParamTypeDescription
keyStringMedia property key

Example

myMedia.del(key: "av_content_id")
 

setProps

setProps(obj: [String: Any])

Declare multiple media properties.

ParamTypeDescription
properties[String: Any]Media properties

Example

myMedia.setProps(obj: [
    "av_content": "My Content",
    "av_content_id": "fg456"
])
 

getProps

getProps() ⇒ [String: Any]

Retrieve multiple media properties.

Example

let props = myMedia.getProps() // {"av_content_id": "fg456", "av_content": "My Content"}
 

delProps

delProps()

Delete multiple media properties.

Example

myMedia.delProps()
 

Playback speed

When changing the playback speed you have to use the method setPlaybackSpeed() specifying the new speed factor as a decimal number.

 

setPlaybackSpeed

setPlaybackSpeed(playbackSpeed: Double)

Declare a change in playback speed.

ParamTypeDescription
playbackSpeedDoublePlayback speed factor

Example

myMedia.setPlaybackSpeed(playbackSpeed: 2.0); // Media playback speed increased by a factor of two

The new playback speed factor will be taken into account when calculating the cursor positions of automated heartbeats events during playback.

If necessary, you can tag the event associated with this speed change by using the myMedia.speed() method.

 

Events tracking

The Insights AV Plugin offers a series of useful functions for measuring events related to your users’ interactions with your content:

 

Media events

 

bufferStart

Event name : av.buffer.start or av.rebuffer.start

bufferStart(cursorPosition: Int, extraProps: [String: Any]?)

Generate an event of buffering at the launch of a media or during the playing.

A buffering flag will automatically generate buffering.heartbeat or rebuffering.heartbeat events depending on the context.

ParamTypeDescription
cursorPositionIntCurrent cursor position (ms)
extraProps[String: Any]?Custom properties

Example

myMedia.bufferStart(
    cursorPosition: 0,
    extraProps: ["customProp": "customValue"]
  )
  
 

play

Event name : av.play

play(cursorPosition: Int, extraProps: [String: Any]?)

Generate a play event (playback attempt).

ParamTypeDescription
cursorPositionIntCurrent cursor position (ms)
extraProps[String: Any]?Custom properties

Example

myMedia.play(
    cursorPosition: 0,
    extraProps: ["customProp": "customValue"]
  )
  
 

playbackPaused

Event name : av.pause

playbackPaused(cursorPosition: Int, extraProps: [String: Any]?)

Generate a pause event.

ParamTypeDescription
cursorPositionIntCurrent cursor position (ms)
extraProps[String: Any]?Custom properties

Example

myMedia.playbackPaused(
  cursorPosition: 1000,
  extraProps: ["customProp": "customValue"]
)
 

playbackResumed

Event name : av.resume

playbackResumed(cursorPosition: Int, extraProps: [String: Any]?)

Generate a resume event, following a pause event.

ParamTypeDescription
cursorPositionIntCurrent cursor position (ms)
extraProps[String: Any]?Custom properties

Example

myMedia.playbackResumed(
  cursorPosition: 1000,
  extraProps: ["customProp": "customValue"]
)
 

playbackStart

Event name : av.start

playbackStart(cursorPosition: Int, extraProps: [String: Any]?)

Generate a playback start event (first media frame).

ParamTypeDescription
cursorPositionIntCurrent cursor position (ms)
extraProps[String: Any]?Custom properties

Example

myMedia.playbackStart(
  cursorPosition: 0,
  extraProps: ["customProp": "customValue"]
)
 

playbackStopped

Event name : av.stop

playbackStopped(cursorPosition: Int, extraProps: [String: Any]?)

Generate a stop event.

ParamTypeDescription
cursorPositionIntCurrent cursor position (ms)
extraProps[String: Any]?Custom properties

Example

myMedia.playbackStopped(
  cursorPosition: 1000,
  extraProps: ["customProp": "customValue"]
)
 

seek

Event name : av.forward ou av.backward

seek(oldCursorPosition: Int, newCursorPosition: Int, extraProps: [String: Any]?)

Generate a seek event.

ParamTypeDescription
oldCursorPositionIntCursor position before seeking (ms)
newCursorPositionIntCursor position after seeking (ms)
extraProps[String: Any]?Custom properties

Example

myMedia.seek(
  oldCursorPosition: 1000,
  newCursorPosition: 2000,
  extraProps: ["customProp": "customValue"]
)
myMedia.seek(
  oldCursorPosition: 2000,
  newCursorPosition: 1000,
  extraProps: ["customProp": "customValue"]
)
 

Contextual events

The following list of events is not taken into account in the calculation of media consumption times. They are one-time contextual events.

 

adClick

Event name : av.ad.click

adClick(extraProps: [String: Any]?)

Generate an ad click event.

ParamTypeDescription
extraProps[String: Any]?Custom properties

Example

myMedia.adClick(
  extraProps: ["customProp": "customValue"]
)
 

adSkip

Event name : av.ad.skip

adSkip(extraProps: [String: Any]?)

Generate an ad skip event.

ParamTypeDescription
extraProps[String: Any]?Custom properties

Example

myMedia.adSkip(
  extraProps: ["customProp": "customValue"]
)
 

close

Event name : av.close

close(extraProps: [String: Any]?)

Measure a closing.

ParamTypeDescription
extraProps[String: Any]?Custom properties

Example

myMedia.close(
  extraProps: ["customProp": "customValue"]
)
 

display

Event name : av.display

display(extraProps: [String: Any]?)

Measure a display.

ParamTypeDescription
extraProps[String: Any]?Custom properties

Example

myMedia.display(
  extraProps: ["customProp": "customValue"]
)
 

error

Event name : av.buffer.start ou av.error

error(message: String, extraProps: [String: Any]?)

Measure an error preventing playback.

ParamTypeDescription
messageStringError message
extraProps[String: Any]?Custom properties

Example

myMedia.error(
  message: "Error loading video",
  extraProps: ["customProp": "customValue"]
)
 

fullscreenOff

Event name : av.fullscreen.off

fullscreenOff(extraProps: [String: Any]?)

Measure full screen deactivation.

ParamTypeDescription
extraProps[String: Any]?Custom properties

Example

myMedia.fullscreenOff(
  extraProps: ["customProp": "customValue"]
)
 

fullscreenOn

Event name : av.fullscreen.on

fullscreenOn(extraProps: [String: Any]?)

Measure full screen activation.

ParamTypeDescription
extraProps[String: Any]?Custom properties

Example

myMedia.fullscreenOn(
  extraProps: ["customProp": "customValue"]
)
 

quality

Event name : av.quality

quality(extraProps: [String: Any]?)

Measure a quality change.

ParamTypeDescription
extraProps[String: Any]?Custom properties

Example

myMedia.quality(
  extraProps: ["customProp": "customValue"]
)
 

share

Event name : av.share

share(extraProps: [String: Any]?)

Measure a sharing.

ParamTypeDescription
extraProps[String: Any]?Custom properties

Example

myMedia.share(
  extraProps: ["customProp": "customValue"]
)
 

speed

Event name : av.speed

speed(extraProps: [String: Any]?)

Measure a speed change.

ParamTypeDescription
extraProps[String: Any]?Custom properties

Example

myMedia.speed(
  extraProps: ["customProp": "customValue"]
)
 

subtitleOff

Event name : av.subtitle.off

subtitleOff(extraProps: [String: Any]?)

Measure subtitles deactivation

ParamTypeDescription
extraProps[String: Any]?Custom properties

Example

myMedia.subtitleOff(
  extraProps: ["customProp": "customValue"]
)
 

subtitleOn

Event name : av.subtitle.on

subtitleOn(extraProps: [String: Any]?)

Measure subtitles activation.

ParamTypeDescription
extraProps[String: Any]?Custom properties

Example

myMedia.subtitleOn(
  extraProps: ["customProp": "customValue"]
)
 

volume

Event name : av.volume

volume(extraProps: [String: Any]?)

Measure sound volume change.

ParamTypeDescription
extraProps[String: Any]?Custom properties

Example

myMedia.volume(
  extraProps: ["customProp": "customValue"]
)
 

Technical events

The following events are automatically generated by the Tracker. You can, however, call up the associated public marking methods if you need spot marking.

 

bufferHeartbeat

Event name : av.buffer.heartbeat

bufferHeartbeat(extraProps: [String: Any]?)

Generate a buffering heartbeat before the playback starts event.

ParamTypeDescription
extraProps[String: Any]?Custom properties

Example

myMedia.bufferHeartbeat(
  extraProps: ["customProp": "customValue"]
)
 

heartbeat

Event name: av.heartbeat

heartbeat(cursorPosition: Int, extraProps: [String: Any]?)

Generate a heartbeat event.

ParamTypeDescription
cursorPositionIntCurrent cursor position (ms)
extraProps[String: Any]?Custom properties

Example

myMedia.heartbeat(
  cursorPosition: 45,
  extraProps: ["customProp": "customValue"]
);

The cursor position is not required for tagging a heartbeat event. By forcing the parameter value to -1, the cursor position will be automatically calculated according to the context (playback speed factor, cursor position of the previous event).

 

rebufferHeartbeat

Event name : av.rebuffer.heartbeat

rebufferHeartbeat(extraProps: [String: Any]?)

Generate a buffering heartbeat after the playback starts event.

ParamTypeDescription
extraProps[String: Any]?Custom properties

Example

myMedia.rebufferHeartbeat(
  extraProps: ["customProp": "customValue"]
)
 

seekBackward

Event name : av.backward

seekBackward(oldCursorPosition: Int, newCursorPosition: Int, extraProps: [String: Any]?)

Generate a backward seeking event.

ParamTypeDescription
oldCursorPositionIntCursor position before seeking (ms)
newCursorPositionIntCursor position after seeking (ms)
extraProps[String: Any]?Custom properties

Example

myMedia.seekBackward(
  oldCursorPosition: 2000,
  newCursorPosition: 1000,
  extraProps: ["customProp": "customValue"]
)
 

seekForward

Event name : av.forward

seekForward(oldCursorPosition: Int, newCursorPosition: Int, extraProps: [String: Any]?)

Generate a forward seeking event.

ParamTypeDescription
oldCursorPositionIntPosition de la tête de lecture avant déplacement (ms)
newCursorPositionIntPosition de la tête de lecture après déplacement (ms)
extraProps[String: Any]?Propriétés personnalisées

Example

myMedia.seekForward(
  oldCursorPosition: 1000,
  newCursorPosition: 2000,
  extraProps: ["customProp": "customValue"]
)
 

seekStart

Event name : av.seek.start

seekStart(oldCursorPosition: Int, extraProps: [String: Any]?)

Generate a beginning of seeking event.

This event is automatically raised when calling the seek(), seekBackward() or seekForward() methods.

ParamTypeDescription
oldCursorPositionIntCursor position before seeking (ms)
extraProps[String: Any]?Custom properties

Example

myMedia.seekStart(
    oldCursorPosition: 1000,
    extraProps: ["customProp": "customValue"]
  )
  
 

Universal tracking method

 

track

The AV Insights universal event tagging method allows standard or custom events to be tracked. This function can be used to replace calls to other event tagging methods (play, playbackStart, bufferStart, etc.).

Event name : event value

track(event: String, options: [String: Any]?, extraProps: [String: Any]?)

Track standard or custom actions.

ParamTypeDescription
eventStringEvent to be generated (see list of standard events at the bottom of the page)
options[String: Any]?Options depending on the event (see list of available options at the bottom of the page)
extraProps[String: Any]?Custom properties

Example

let tracker = ATInternet.sharedInstance.defaultTracker
let myMedia = tracker.avInsights.Media(heartbeat: 5, bufferHeartbeat: 5)
// Buffer tagging
myMedia.track(event: "av.buffer.start", options: ["av_position": 0], extraProps: nil)
// Re-buffer tagging
myMedia.track(event: "av.rebuffer.start", options: ["av_position": 0], extraProps: nil)
// Play tagging
myMedia.track(event: "av.play", options: ["av_position": 0], extraProps: nil)
// Playback start tagging
myMedia.track(event: "av.start", options: ["av_position": 0], extraProps: nil)
// Playback pause tagging
myMedia.track(event: "av.pause", options: ["av_position": 10], extraProps: nil)
// Playback resume tagging
myMedia.track(event: "av.resume", options: ["av_position": 10], extraProps: nil)
// Playback stop tagging
myMedia.track(event: "av.stop", options: ["av_position": 20], extraProps: nil)
// Seek forward tagging
myMedia.track(event: "av.forward", options: ["av_previous_position": 10, "av_position": 20], extraProps: nil)
// Seek backward tagging
myMedia.track(event: "av.backward", options: ["av_previous_position": 20, "av_position": 10], extraProps: nil)
// Ad click tagging
myMedia.track(event: "av.ad.click", options: nil, extraProps: nil)
// Ad skip tagging
myMedia.track(event: "av.ad.skip", options: nil, extraProps: nil)
// Error tagging
myMedia.track(event: "av.error", options: ["av_player_error": "Player error"], extraProps: nil)
// Display tagging
myMedia.track(event: "av.display", options: nil, extraProps: nil)
// Close tagging
myMedia.track(event: "av.close", options: nil, extraProps: nil)
// Volume tagging
myMedia.track(event: "av.volume", options: nil, extraProps: nil)
// Subtitle on tagging
myMedia.track(event: "av.subtitle.on", options: nil, extraProps: nil)
// Subtitle off tagging
myMedia.track(event: "av.subtitle.off", options: nil, extraProps: nil)
// Full screen on tagging
myMedia.track(event: "av.fullscreen.on", options: nil, extraProps: nil)
// Full screen off tagging
myMedia.track(event: "av.fullscreen.off", options: nil, extraProps: nil)
// Quality tagging
myMedia.track(event: "av.quality", options: nil, extraProps: nil)
// Speed tagging
myMedia.track(event: "av.speed", options: nil, extraProps: nil)
// Share tagging
myMedia.track(event: "av.share", options: nil, extraProps: nil)
// Custom tagging
myMedia.track(event: "custom", options: nil, extraProps: ["customParam": "customValue"])
 

Complete tagging example

let tracker = ATInternet.sharedInstance.defaultTracker
let myMedia = tracker.avInsights.Media(heartbeat: 5, bufferHeartbeat: 5) // Set heartbeats value (5 seconds)
let properties: [String: Any] = [
    "av_content_id": "fge234",
    "av_content": "myContent",
    "av_content_type": "Video",
    "av_content_duration": 10000,
    "av_content_genre": ["entertainment"],
    "av_content_version": "short",
    "av_player": "HTML5_V123",
    "av_player_version": "1b",
    "av_player_position": "top",
    "av_broadcasting_type": "On Demand",
    "av_publication_date": 1562055880,
    "av_show": "The gist of the game",
    "av_show_season": "Season 1",
    "av_episode_id": "3134",
    "av_channel": "INFO",
    "av_author": "AT Internet",
    "av_broadcaster": "Direction 123",
    "av_language": "EN",
    "av_subtitles": "FR",
    "av_launch_reason": "Auto"
]
// Set media properties
myMedia.setProps(obj: properties)
// Play attempt (cursor position 0 second)
myMedia.play(cursorPosition: 0, extraProps: nil)
// Buffering before playback start (cursor position 0 second)
myMedia.bufferStart(cursorPosition: 0, extraProps: nil)
// Playback start (cursor position 0 second)
myMedia.playbackStart(cursorPosition: 0, extraProps: nil)
// Buffering after 5 seconds of playback
myMedia.bufferStart(cursorPosition: 5000, extraProps: nil)
// Seek action (backward from cursor position 5 seconds to cursor position 3 seconds)
myMedia.seek(oldCursorPosition: 5000, newCursorPosition: 3000, extraProps: nil)
// Playback resume (cursor position 3 seconds)
myMedia.playbackResumed(cursorPosition: 3000, extraProps: nil)
// Playback pause (cursor position 9 seconds)
myMedia.playbackPaused(cursorPosition: 9000, extraProps: nil)
// Playback resume (cursor position 9 seconds)
myMedia.playbackResumed(cursorPosition: 9000, extraProps: nil)
// Playback stop (cursor position 15 seconds)
myMedia.playbackStopped(cursorPosition: 15000, extraProps: nil)
 

Annexes

 

Media properties list

PropertyTypeDescription
av_playerStringPlayer identifier
av_player_versionStringPlayer version
av_player_positionStringPlayer position
av_contentStringContent label
av_content_idStringContent identifier
av_content_typeStringContent type (Audio/Video/Gaming…)
av_content_durationIntContent duration (milliseconds)
av_content_versionStringContent version
av_content_genre[String]Content genre (news/entertainment…)
av_content_linkedStringLinked content
av_content_duration_rangeStringContent duration range (‘0-10’…)
av_broadcasting_typeStringBroadcasting type (live, VOD)
av_ad_typeStringAd type (Pre-roll/Mid-Roll/Post-Roll)
av_publication_dateIntPublication date (secondes -format UTC)
av_showStringShow label
av_show_seasonStringShow season
av_episode_idStringEpisode identifier
av_episodeStringEpisode label
av_channelStringChannel
av_authorStringAuthor name
av_broadcasterStringBroadcaster label
av_auto_modeBoolIs playback auto?
av_languageStringMedia language
av_subtitlesStringSubtitles
av_launch_reasonStringLaunch reason
 

List of standard events

Event
av.heartbeat
av.buffer.heartbeat
av.rebuffer.heartbeat
av.play
av.buffer.start
av.rebuffer.start
av.start
av.resume
av.pause
av.stop
av.forward
av.backward
av.seek.start
av.ad.click
av.ad.skip
av.error
av.display
av.close
av.volume
av.subtitle.on
av.subtitle.off
av.fullscreen.on
av.fullscreen.off
av.quality
av.speed
av.share
 

List of available options

OptionDescription
av_positionCurrent cursor position (ms)
av_previous_positionPrevious cursor position (ms)
av_player_errorError preventing playback
Last update: 06/01/2021