SRGAnalytics

SRGAnalytics

Official documentation

Script URL

JS script : https://colibri-js.akamaized.net/penguin/tc_SRGGD_11.js

Variables list

  • event_id: init | play | stop | pos | pause | seek | uptime | eof
  • event_timestamp: Seems to be generated automatically from the documentation, but the TP overrides it
  • event_name: NA TP seems to not sending this variable
  • event_source: NA TP seems to not sending this variable
  • event_name: NA TP seems to not sending this variable
  • event_value: NA TP seems to not sending this variable
  • navigation_environment: prod | preprod
  • media_subtitles_on: string true | false
  • media_timeshift: need better description
  • media_quality: SD | HD ?
  • media_bandwidth: NA for the web, 64000
  • media_volume: from 0 to 100
  • media_embedding_url:
  • media_player_name: videojs | letterbox-web ?
  • media_chromecast_selected: boolean true | false
  • media_player_version: player's version
  • media_player_display: is the player mode, on the TP : inline, embed etc..
  • media_audio_track: NA
  • media_position_real: NA
  • media_time_spent: NA
  • device_id: NA
  • user_id_log_in: NA only RTS has log in today
  • media_thumbnail: Not required by the spec but sended by the TP
  • media_bu_distributer: Not required by the spec but sended by the TP

Sequence stories

Story 1 (AoD/VOD-basics): A VoD is played. The user does not interact with the player. The VoD plays to its end.

Hints:

  • Media sessions always start with PLAY. They end with STOP or EOF (or with PAUSE or last POS)
  • POS is sent ever 30s

Story 2 (livestream-basics A): A Livestream is played. The user does not interact with the player. After 61 seconds, playback is paused.

Hints:

  • Media sessions always start with PLAY. They end with STOP (or, worse for data quailty, with PAUSE or last POS/UPTIME)
  • UPTIME is sent only for livestreams
  • POS is sent ever 30s, UPTIME every 60s with inital UPTIME after 30s.
  • This is the interval: 30s: POS + UPTIME; 60s: POS; 90s: POS + UPTIME; ...

Story 3 (Seeking a VoD/AoD): A VoD is played. User seeks in the VoD/AoD.

Hints:

  • Once the Media Player slider is released (seek is over), another action to finish up the seeking is initiated. Typically this is PLAY. For that second PLAY, the media position has altered.

Story 4 (Seeking a livestream): A Livestream is played. User goes back in the livestream.

Hints:

  • Once the Media Player slider is released (seek is over), another action to finish up the seeking is initiated. Typically this is PLAY. For that second PLAY, the a new variable, media_timeshift is passed.
  • For livestreams media_position is always the "time passed on your watch" - regardless of the SEEK event. So, if 1 second after PLAY the slider is moved back 600 seconds, then:
  1. The the value of media_timeshift is '600'.
  2. The value of media_position is '1'.

Constructor

new SRGAnalytics(player, optionsopt)

Creates an instance of SRGAnalytics.

Parameters:
NameTypeAttributesDefaultDescription
playerPlayer

The player instance

optionsSRGAnalyticsOptions<optional>
{}

Configuration options

Properties
NameTypeAttributesDefaultDescription
debugboolean<optional>
false

Enables debug mode if set to true

environmentstring<optional>
'prod'

The environment in which the data is sent

playerVersionstring<optional>
'none'

The version of the player

tagCommanderScriptURLstring<optional>
'//colibri-js.akamaized.net/penguin/tc_SRGGD_11.js'

The URL for the Tag Commander script

Methods

beforeunload()

Sent when the window, the document and its resources are about to be unloaded.

clearTimers()

Clear timers used to send uptime and heartbeat.

currentTime() → {Number}

Get the tracked current time in seconds.

Returns:

current time in seconds

Type: 
Number

debug() → {Boolean|undefined}

Get or set debug mode.

Returns:
Type: 
Boolean | undefined

destroy()

Destroy all properties and setIntervals to avoid mixing media sessions.

dispose()

Dispose all listeners used to send analytics data to TagCommander.

Calls beforeunload to send a notify stop. Clear intervals and timeouts.

Used events

  • beforeunload
  • emptied
  • ended
  • loadstart
  • loadeddata
  • play
  • pause
  • timeupdate

emptied()

Sent before a new media is loading.

  • Destroy all properties.
  • Send a notify stop if the media is not ended and new media is about to be loaded.

ended()

Sent when playback completes.

flush()

Flush the queued events when tc event script is loaded.

getCurrentAudioTrack() → {String}

Get the language of the current audio track.

Returns:

empty string or uppercase language.

Type: 
String

getCurrentTextTrack() → {String}

Get the language of the current text track.

Returns:

empty string or uppercase language.

Type: 
String

getDvrWindowPosition() → {Number}

Get the position inside the dvr window where the 0 represents the live edge

Returns:

0 or the position in milliseconds

Type: 
Number

getDvrWindowSize() → {Number}

Get the size of the live DVR window in milliseconds.

Returns:

DVR window size in milliseconds

Type: 
Number

getElapsedPlaybackTime() → {Number}

Get the elapsed playback time in seconds.

Returns:

elapsed time in seconds

Type: 
Number

getElapsedPlayingTime() → {Number}

Get the elapsed playing time in seconds.

Returns:

elapsed time in seconds

Type: 
Number

getEventLabels(eventName) → {Object}

Set all event labels to be sent to TagCommander. The event labels are updated whenever a new event occurs.

Parameters:
NameTypeDescription
eventNameString

init | play | stop | pos | pause | seek | uptime | eof

Returns:

JSON to be sent to TagCommander

Type: 
Object

getInternalLabels()

Set all internal labels to be sent to TagCommander. Internal labels are assigned once at initialisation time.

heartBeat()

The action pos should be sent regularly every 30 seconds. It is used for tracking the viewed chapters of a video and the last position of the video, in case the user ends the video by closing the browser tab/window.

  • pos should be sent when the media player is in "play mode".
  • once the video is paused or stopped, the timer for sending these actions must be stopped.

initCallbacks()

Initialize callbacks used to send analytics data to TagCommander.

Used events

  • beforeunload
  • emptied
  • ended
  • loadstart
  • loadeddata
  • play
  • pause
  • ratechange
  • seeking
  • timeupdate
  • waiting

initListeners()

Initialize all listeners used to send analytics data to TagCommander.

Used events

  • beforeunload
  • dispose
  • emptied
  • ended
  • loadstart
  • loadeddata
  • play
  • pause
  • timeupdate
  • waiting

initScript()

Initialize TagCommander script dynamically and add it to the DOM

isAudioDescriptionEnabled() → {Boolean}

Check if the audio description track is enabled.

Returns:

true if enabled false otherwise.

Type: 
Boolean

isAudioTrackEnabled() → {Boolean}

Check if the audio track is enabled.

Returns:

true if enabled false otherwise.

Type: 
Boolean

isMediaDvr() → {Boolean}

Check if the media is a live with DVR.

Returns:

true if it DVR false otherwise.

Type: 
Boolean

isMediaLive() → {Boolean}

Check if the media is a live.

Returns:

true if live false otherwise.

Type: 
Boolean

isMediaOnDemand() → {Boolean}

Check if the media is an on demand.

Returns:

true if on demand false otherwise.

Type: 
Boolean

isTextTrackEnabled() → {Boolean}

Check if the text track is enabled.

Returns:

true if enabled false otherwise.

Type: 
Boolean

isTrackerDisabled() → {Boolean}

Check if the tracker is disabled.

Returns:

true if disabled false otherwise.

Type: 
Boolean

loadeddata()

The first frame of the media has finished loading.

loadstart()

Sent when loading of the media begins.

log(eventName, eventMetadata, severity)

Event logger that prints the current event, event labels and internal labels in the browser's console.

Parameters:
NameTypeDefaultDescription
eventNameString

init | play | stop | pos | pause | seek | uptime | eof

eventMetadataObject

event metadata object

severityStringlog

log | warn | error

notify(eventName)

Notify TagCommander all event and internal labels. If tc script is not available it queues all pending events.

Parameters:
NameTypeDescription
eventNameString

init | play | stop | pos | pause | seek | uptime | eof

pause()

Sent when the playback state is changed to paused (paused property is true). Pause event is sent if :

  • The player is not scrubbing
  • The stream is not a live only
  • The current time is strictly inferior to the duration

play()

Sent when the playback state is no longer paused, as a result of the play method, or the autoplay attribute.

rateChange()

Sent to ComScore when the playback rate changes.

reloadTagCommanderContainer()

Reload the tagCommander container and set all ComScore labels

seeking()

Sent when the current time is modified by the player's currentTime API.

timeShifted() → {String}

Gets the number of seconds that separate from the live edge that is represented by 0.

Returns:
Type: 
String

timeUpdate()

Track current time updates delayed by a tick.

updateSrcMediaData()

Update the src media data.

uptime()

Calculate the uptime when playing a live stream with or without DVR

Rules:

  • Send the first uptime after 30 seconds
  • Send uptime each 60 seconds after the 30 seconds
  • Uptime is sent only when playing

waiting()

ComScore: It's expected notifyBufferStart() to be called when the player starts buffering and a call to notifyBufferStop() when content resumes after buffering.

See
  • Item 2: https://jira.srg.beecollaboration.com/browse/PLAY-2628 After the issue PLAYRTS-321
  • Fix: https://jira.srg.beecollaboration.com/browse/PLAYRTS-321?focusedCommentId=201023&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-201023
  • Fix: https://jira.srg.beecollaboration.com/browse/PLAYRTS-3065

(static) now() → {Number}

Return the current timestamp in seconds.

Returns:

Timestamp in seconds

Type: 
Number