This article shows how to set up video tracking in Tealium iQ for Vzaar videos.

In this article:


There are currently two ways of implementing the Vzaar Video Player:

  1. iFrame embed : this is where the video player is embedded into the page with a simple iFrame embedding script. The script looks like
    <iframe allowFullScreen allowTransparency="true" class="vzaar-video-player" frameborder="0" height="240" id="vzvd-1556961" mozallowfullscreen name="vzvd-1556961" src="" title="vzaar video player" type="text/html" webkitAllowFullScreen width="448"></iframe>
  2. HTML Embed : This is also done with a simple embed script but instead of using an iFrame  this is a block of JavaScript code that gets placed on the page. This block of code will look something like:
    <div id='video-container'>
        <div class='vzaar_media_player'>
            <object data='' height='324' id='video' type='application/x-shockwave-flash' width='576'>
            <param name='allowFullScreen' value='true' />
            <param name='allowScriptAccess' value='always' />
            <param name='wmode' value='transparent' />
            <param name='movie' value='' />
            <param name='flashvars' value='apiOn=true&amp;colourSet=grey&amp;colourBg=#ffffff&amp;border=none&amp;socialSharing=0,0,0' />
            <video controls='' height='324' id='vzvid' onclick=';' poster='' preload='none' src='' width='576'></video>
        <div id='vid-info' style="font-family: Courier, monospace; font-size: 13px;">
            <a href='#' id='addBookmark'>Add Bookmark</a>
            <a href='#' id='resetBookmark'>Reset Bookmark</a>

Both methods require the JavaScript API to be loaded. This is the script for the client.js file from Vzaar: 

<script src="" type="text/javascript"></script>

The Vzaar client.js content needs to load before the event listener code (below) is added to Tealium iQ. The best practice method for loading this file would be to have the script load directly on the page before the utag.js file. Otherwise it can be added via JS Code Extension scoped to Pre Loader or in a Tealium Custom Container Tag. 

Attached is a block of code that you can copy and paste into a JavaScript Code Extension. This extension should be scoped to Pre Loader. Once pasted into the JavaScript code extension there are four configuration fields at the very top of the code that you can customize: 

  1. video_events 
    This is a list of events that you would like to track with the code. By default this is set up to track play, pause, complete and milestones. Vzaar currently only has three events that are tracked: playState, progress, and interaction. All three are enabled by default.
  2. milestone_percentages
    This is a list of percentages that you would like to track as milestones. For the Vzaar Player the milestones must be rounded to an even "10" value. By default this is set to trigger an event when the video has reached 20, 50, 70, 90 percent complete. However, this can be customized to your specific milestones. You can deactivate milestone tracking by removed the "progess" event from the video_events list.
  3. player_element_id
    This value needs to match the id of the element that is embedding the video player. If using the iframe method this is the id of the iframe. If using the HTML method this should be id of the video object element.
    • If your iframe embed code is the above code example, then this value would be:  "vzvd-1556961"
    • If using the HTML method and you were using the above code example, this value would be: "video" 
  4. player_type
    This is the method you are using to embed your video. Because the two embed methods use different functions to add the listeners, this variable is used to determine which function will be used. The possible options are: "iframe" or "html". 

The attached script will work for both the html and iframe embed methods. This code needs to load as soon as possible so that the PlayerReady function is defined before the video is loaded. Once the video is loaded it will call the PlayerReady function, and the extension is not loaded before the video the tracking WILL NOT work. 

iFrame Embed

If using the iframe embed code there is one nuance specific to this method. Notice in the above sample iframe embed script that the "src" of the iframe has a parameter at the end of it that enables the tracking API for the event listeners:


Thus, 'apiOn=true' must be appended to the end of the "src" to enable Vzaar video tracking. 

Output Variables

This code will output a set of data sources that you can add in the UI and then use to send data to your tag vendors. The variables are as follows:

  • event_type - This will always equal "video" for these events.
  • event_name - These are the default names that will be output.
    "play", "pause", "resume", "complete", "milestone"
    If you have customized the video_events variable as mentioned above then you may see something like: jwplayerMute for the onMute event. 
  • video_position - This will output the position, in seconds, of the video when one of the events took place. i.e. pause or milestone.
  • video_duration - This returns the over length of the video.
  • video_milestone - This outputs the milestone number "1" and the milestone percentage "25." This allows you to see where your users are dropping out of the videos. Example: "M:1:25" 

Attached is a csv file with these variables and descriptions for easy uploading into the Data Sources tab of the Tealium UI. 

This code will call, but there are lines that are commented out that will support the Media Module for Adobe Analytics. The thought behind calling is then you'll have another extension that will determine when to call the Media Module functions so this extension is more "plug and play" with less customizations. 

Source Code

var video_events = ["playState","progress","interaction"];  // Possible values are "playState", "progress" and/or "integration"
var milestone_percentages = ["10","20","30","40","90"];  // These must be rounded to the nearest 10
var player_element_id = "video";
var player_type = "html"; // Possible values are "iframe" or "html"

var played = false;
var m1 = false;
var m2 = false;
var m3 = false;
var m4 = false;

// Call in Vzaar event listeners
window._tealium_VZ = {
  name : "Vzaar",
  init_tries : 0,
  eventsAdded : false,
  events : video_events,
  milestone_percentages : milestone_percentages,
  mediaEventHandler :  function (pEvent) {
    pos = _tealium_VZ.player_object.getTime();
    dur = _tealium_VZ.player_object.getTotalTime();
     if (pEvent=="mediaStarted" || pEvent=="started") {
      played = true;
      utag.DB("**** video started ****");{event_type:"video",event_name:"play"})
      ////, video_duration, video_player);
      ////, 0);
    } else if(pEvent=="resume"){
      //, 0);
      _tealium_VZ.pause = false;{event_type:"video",event_name:"resume",video_position:pos,video_duration:dur})
      utag.DB("**** video resumed ****");
    }else if(pEvent=="pause"){
      //s.Media.stop(video_name, video_position);
      _tealium_VZ.pause = true;{event_type:"video",event_name:"pause",video_position:pos,video_duration:dur})
      utag.DB("**** video paused****");
      utag.DB("**** Position: " + pos);
      utag.DB("**** Total Duration: " + dur);
    }else if(pEvent=="mediaEnded"){
      //s.Media.complete(video_name, video_position);
      //s.Media.stop(video_name, video_position);
      played = false;
      utag.DB("**** video complete****");
      var ms = pEvent.replace(/[^0-9]/g, "")
      for(var i=0;i<_tealium_VZ.milestone_percentages.length;i++){
            var ms_num =(i+1);
            utag.DB("**** "+_tealium_VZ.milestone_percentages[i]+"% viwed****");
// Attaching Event Listeners for Begin, Play, Stop, and Video Completion
// Each Event Handler has a callback function attached to it (mediaEventHandler) which will be called when the event occurs  
  addEvents : function(a){
    utag.DB("***** Adding Events ******");
        for(var i=0;i<video_events.length;i++){
        for(var i=0;i<video_events.length;i++){
  init : function(){
    //utag.DB("Connecting Tealium with Vzaar object");
    if(typeof vzPlayer!="undefined"){
	  vz_player = new vzPlayer(player_element_id)
                utag.DB("TEALIUM: Connecting Tealium with Oyala Player - SUCCESS");
                _tealium_VZ.player_object = vz_player;
                utag.DB("****** Events Added ******");
                _tealium_VZ.eventsAdded = true;
            window.vzaarPlayerReady = function() {
                utag.DB("*********** Video Ready **************");
                utag.DB("TEALIUM: Connecting Tealium with Oyala Player - SUCCESS");
                vzPlayer = document.getElementById(player_element_id);	
                _tealium_VZ.player_object = vzPlayer;
                utag.DB("****** Events Added ******");
                _tealium_VZ.eventsAdded = true;
                _tealium_VZ.readyFunction = true;
    }else if(!_tealium_VZ.eventsAdded){
      // If Vzaar object is not defined we will increment the number of tries by 1
      _tealium_VZ.init_tries += 1;
      //Stop trying to connect to the Video Player if tried 100 times
        utag.DB("TEALIUM: Cannot connect to Vzaar Video");
      // Calls init function repeatedly either 100 times or Vzaar Object is defined
      setTimeout(function(){_tealium_VZ.init()}, 100);

if(typeof _tealium_VZ.videoPlayer == "undefined"){


Version history
Last update:
‎10-31-2020 09:33 AM
Updated by: