Track core playback on Chromecast
- Topics:
- Media Analytics
CREATED FOR:
- User
- Admin
- Developer
This documentation covers tracking in version 2.x of the SDK.
-
Initial tracking setup
Identify when the user triggers the intention of playback (the user clicks play and/or autoplay is on) and create a
MediaObject
instance.MediaObject
API reference:mediaObject = ADBMobile.media.createMediaObject(<name>, <id>, <duration>, <streamType>, <mediaType>);
StreamType
constants:MediaType
constants: -
Attach video metadata
Optionally attach standard and/or custom video metadata objects to the video tracking session through context data variables.
-
Standard video metadata
Implement standard metadata on Chromecast
NOTE
Attaching the standard video metadata object to the media object is optional. -
Custom metadata
Create a variable object for the custom variables and populate with the data for this video. For example:
/* Set custom context data */ var customVideoMetadata = { isUserLoggedIn: "false", tvStation: "Sample TV station", programmer: "Sample programmer" };
-
-
Track the intention to start playback
To begin tracking a media session, call trackSessionStart on the
media
object.ADBMobile.media.trackSessionStart(mediaObject, customVideoMetadata);
IMPORTANT
trackSessionStart
tracks the user intention of playback, not the beginning of the playback. This API is used to load the video data/metadata and to estimate the time-to-start QoS metric (the time duration betweentrackSessionStart
andtrackPlay
).NOTE
The second value is the custom video metadata object name that you created in step 2. If you are not using custom video metadata, simply send an empty object for thedata
argument intrackSessionStart
, as shown in the commented out line in the iOS example above. -
Track the actual start of playback
Identify the event from the video player for the beginning of the video playback, where the first frame of the video is rendered on the screen, and call trackPlay:
ADBMobile.media.trackPlay();
-
Update playhead value
Update
mediaUpdatePlayhead
’ position value multiple times when the playhead changes.
For video-on-demand (VOD), the value is specified in seconds from the beginning of the media item.
For live streaming, if the player does not provide information about the content duration, the value can be specified as the number of seconds since midnight UTC of that day.ADBMobile().media.updatePlayhead(position)
NOTE
Consider the following when calling themedia.updatePlayhead
API:- When using progress markers, the content duration is required and the playhead needs to be updated as number of seconds from the beginning of the media item, starting with 0.
- When using media SDKs, you must call the
media.updatePlayhead
API at least once per second.
-
Track the completion of playback
Identify the event from the video player for the completion of the video playback, where the user has watched the content until the end, and call trackComplete:
ADBMobile.media.trackComplete();
-
Track the end of the session
Identify the event from the video player for the unloading/closing of the video playback, where the user closes the video and/or the video is completed and has been unloaded, and call trackSessionEnd:
ADBMobile.media.trackSessionEnd();
IMPORTANT
trackSessionEnd
marks the end of a video tracking session. If the session was successfully watched to completion, where the user watched the content until the end, ensure thattrackComplete
is called beforetrackSessionEnd
. Any othertrack*
API call is ignored aftertrackSessionEnd
, except fortrackSessionStart
for a new video tracking session. -
Track all possible pause scenarios
Identify the event from the video player for video pause and call trackPause:
ADBMobile.media.trackPause();
Pause Scenarios
Identify any scenario in which the Video Player will pause and make sure that
trackPause
is properly called. The following scenarios all require that your app calltrackPause()
:- The user explicitly hits pause in the app.
- The player puts itself into the Pause state.
- (Mobile Apps) - The user puts the application into the background, but you want the app to keep the session open.
- (Mobile Apps) - Any type of system interrupt occurs that causes an application to be backgrounded. For example, the user receives a call, or a pop up from another application occurs, but you want the application to keep the session alive to give the user the opportunity to resume the video from the point of interruption.
-
Identify the event from the player for video play and/or video resume from pause and call trackPlay:
ADBMobile.media.trackPlay();
TIP
This may be the same event source that was used in Step 4. Ensure that eachtrackPause()
API call is paired with a followingtrackPlay()
API call when the video playback resumes.
- Tracking scenarios: VOD playback with no ads
- Sample player included with the Chromecast SDK for a complete tracking example.