Measuring Additional Metrics using Media.monitor

You can define a custom Media.monitor method to track additional video metrics.

A custom Media.monitor method gives you the most granular control over video tracking. AppMeasurement automatically calls the Media.monitor method in the following circumstances:

Use this functionality to monitor the status of each video that is currently playing. With it, you can setup additional variables (Props, eVars, Events) and call Media.track based on the current state of the video as it is playing.

s.Media.monitor(s, media)

This method takes the following parameters:

s: The AppMeasurement instance.

media: An object with members providing the state of the video. These members include:

State Property Description The name of the video given in the call to
media.length The length of the video in seconds given in the call to
media.openTime A Date object set to the time video tracking started.
media.offset The current offset into the video, in seconds.
media.percent The current offset into the video, as a percentage of the video length ((media.offset / media.length) * 100).
media.timePlayed The total video playback time, in seconds. This includes replay time due to rewind, and excludes time skipped by fast forwarding.
media.playerName The name of the media player given in the call to

The event that initiated the call to the Media.monitor method. Options include the following:

OPEN: The start of video playback. For a non-autoTrack (manual) implementation, this is the first time is called after calling

PLAY: Video playback restarted.

STOP: Video playback stopped due to pause, seek forward or backwards, scrubbing started, etc.

CLOSE: The end of video playback. For a non-autoTrack (manual) implementation, this is when Media.close is called.

MONITOR: A check of the video state, which occurs every second.

MILESTONE: A video milestone was reached, as defined by the Media.trackMilestones method. The media.milestone property identifies the specific milestone that was reached.

SECONDS: The playback time specified by media.trackSeconds has been reached.

media.eventFirstTime A boolean property. When set to true, indicates the media.mediaEvent occurred for the first time. If media.mediaEvent = "MILESTONE" a true value indicates that this is the first time to reach the video milestone identified in media.milestone.

The milestone reached during video playback, as defined in the Media.trackMilestones method.

This property is only set when media.mediaEvent is set to "MILESTONE".

media.player Player-specific data created by some autoTrack implementations.
media.player.metadata Player-specific method for retrieving video metadata from the player.

A custom Media.monitor method should do similar to the following:

Define a method or function for Media.monitor

To create a custom Media.monitor method you can set Media.monitor to an anonymous function or a class method. The anonymous function or class method you define should take the AppMeasurement instance and media object as shown in the media monitor reference.

//JavaScript or Flash anonymous function example
s.Media.monitor = function (s,media)  {
//Silverlight class method example
s.Media.monitor = new AppMeasurement_Media_Monitor(myMediaMonitor);
//OSMF anonymous function example
s.Media.monitor = function (s:Object,media:Object) {

Media.monitor Code Sample

The following code sample demonstrates using Media.monitor to send custom variables.

/* Import line for ActionScript 3 */
import com.omniture.AppMeasurement;

/* Uncomment for ActionScript 2 with Flash Player 8+ and comment out other import lines */
/* import com.omniture.AS2.AppMeasurement; */

/* Uncomment for ActionScript 2 with Flash Player 6, 7, or Lite and comment out other import lines */
/* import com.omniture.AS2.FPL.AppMeasurement; */

var s:AppMeasurement = new AppMeasurement();
/* Uncomment for Flex and comment out addChild(s); */
/* rawChildren.addChild(s); */

/* Specify the Report Suite ID(s) to track here */
s.account = "jdoe";
/* Turn on and configure debugging here */
s.debugTracking = true;
s.trackLocal = true;
/* You may add or alter any code config here */
s.pageName = "";
s.pageURL = "";
s.charSet = "UTF-8";
s.currencyCode = "USD";


/* Turn on and configure ClickMap tracking here */
s.trackClickMap = true;
s.movieID = "";

/* WARNING: Changing any of the below variables will cause drastic changes
to how your visitor data is collected.  Changes should only be made
when instructed to do so by your account manager.*/
s.visitorNamespace = "corp1";
s.trackingServer = "";
var tracked25:Boolean
var tracked50:Boolean
var tracked75:Boolean
var fireRequest:Boolean

s.Media.trackUsingContextData = true;

s.Media.contextDataMapping = {

s.Media.monitor = function (s,media){
    if ((media.event == "MILESTONE") && (media.eventFirstTime)) {
     if (media.milestone == 25) {
          s.prop51 = " : " +"25%";
          fireRequest = true;
     if (media.milestone == 50) {
          s.prop51 = " : " +"50%";
          fireRequest = true;
     if (media.milestone == 75) {
          s.prop51 = " : " +"75%";
          fireRequest = true;
     if (fireRequest) {
          fireRequest = false;
    if(media.event=="OPEN") {
        s.prop50="Home page"

    if(media.event=="CLOSE") { " : " +"100%"


    function sendRequest(){

The following custom Media.monitor method sets eVar1 to the “series” key, eVar2 to the “season” key, and eVar3 to the “episode” key in the namespace using OSMF metadata:

s.Media.monitor = function (s:Object,media:Object) {
    s.trackVars = "events,eVar1,eVar2,eVar3";
    s.trackEvents = "event1,event2";
    s.eVar1 = media.player.metadata("","series");
    s.eVar2 = media.player.metadata("","season");
    s.eVar3 = media.player.metadata("","episode");
    if (media.mediaEvent == "OPEN") { = "event1";
    } else if (media.mediaEvent == "CLOSE") { = "event2";

The following example shows a Media.monitor implementation in Silverlight: = new AppMeasurement_Media_Monitor(myMediaMonitor);

// ...

// custom variables (Props, eVars, Events) are sent automatically on an OPEN event, and when manually tracked here (in media monitor below)
private void myMediaMonitor(AppMeasurement s,AppMeasurement_Media_State media) {
     if (media.mediaEvent == "OPEN") { //executes when the video opens
          s.Media.trackVars = "eVar1,events";
          s.Media.trackEvents = "event1";
 = "event1";
          s.eVar1 =;
     if (media.mediaEvent == "CLOSE") { //executes when the video completes
          s.Media.trackVars = "eVar1,events";
          s.Media.trackEvents = "event4";
 = "event4";
          s.eVar1 =;