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

In this article:


Attached is a block of code that you can copy and paste into a JavaScript Code Extension. Once pasted into the extension there are three 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, but you can simply add events to this like like "mute" to track when a user mutes the volume. You can also see a list of available events here.
  2. milestone_percentages
    This is a list of percentages that you would like to track as milestones. By default this is set to trigger an event when the video has reached 25, 50, 75 and 90 percent complete. However, this can be customized to your specific milestones. You can deactivate milestone tracking by removed the "onTime" event from the video_events list. 
  3. player_object_name
    When the Ooyala library loads on the page it should call a function called "OO.Player.create." This creates the video on the page and gets it ready for viewing. When this function is called it will create an object of data points and function specific to that video player. It would look something like: 
     window.player = OO.Player.create('playerwrapper','w3ZHc0Njr33Tdp-RRcwfZMjaOrmzOP82',{
        // More code here doing something.   

The player_object_name variable should contain "player" in this case. In the JavaScript code provided below you can see that "window.player" gets set to the object that is created from calling "OO.Player.create." This object (player) is getting set in the global scope (window) so it can be used by other libraries like Tealium. 

This extension code will wait until the Ooyala player has been defined then run through the necessary functions to attach the listeners. 

Though the code has logic to wait for the player to be defined, the JavaScript Code extension where you paste the code should be scoped to DOM Ready.

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 available 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" 
  • 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 tells 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 = ["playing","playheadTimeChanged","paused"];
var milestone_percentages = ["25","50","75","90"];
var player_object_name = "player";

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

// Call in Ooyala event listeners
window._tealium_OO = {
  name : "Ooyala",
  init_tries : 0,
  eventsAdded : false,
  events : video_events,
  milestone_percentages : milestone_percentages,
// 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(){
        for(var i=0;i<video_events.length;i++){
          if(video_events[i]=="playing" || video_events[i]=="paused" || video_events[i]=="playheadTimeChanged"){
          }else {
    pos = _tealium_OO.player_object.getPlayheadTime();
    dur = _tealium_OO.player_object.getDuration();
    if (!played) {
      played = true;
      utag.DB("**** video started ****");{event_type:"video",event_name:"play"})
      ////, video_duration, video_player);
      ////, 0);
    } else{
      //, 0);
      _tealium_OO.pause = false;{event_type:"video",event_name:"resume",video_position:pos,video_duration:dur})
      utag.DB("**** video resumed ****");
    pos = _tealium_OO.player_object.getPlayheadTime();
    dur = _tealium_OO.player_object.getDuration();
    //s.Media.stop(video_name, video_position);
    }else if(!_tealium_OO.pause){
      _tealium_OO.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);
  complete : function(e,pos,dur){
    pos = _tealium_OO.player_object.getPlayheadTime();
    dur = _tealium_OO.player_object.getDuration();
    //s.Media.complete(video_name, video_position);
    //s.Media.stop(video_name, video_position);
    played = false;
    utag.DB("**** video complete****");
  playheadTimeChanged: function(data,pos,dur){
    pos = _tealium_OO.player_object.getPlayheadTime();
    dur = _tealium_OO.player_object.getDuration();
    var pct = parseFloat(pos / dur) * 100;
    if (pct > _tealium_OO.milestone_percentages[0] && !m1) {
      m1 = true;{event_type:"video",event_name:"milestone",video_milestone:"M:1:"+_tealium_OO.milestone_percentages[0],video_position:pos,video_duration:dur})
      utag.DB("**** 25% viwed****");
    } else if (pct > _tealium_OO.milestone_percentages[1] && !m2) {
      m2 = true;{event_type:"video",event_name:"milestone",video_milestone:"M:2:"+_tealium_OO.milestone_percentages[1],video_position:pos,video_duration:dur})
      utag.DB("**** 50% viewed****");
    } else if (pct > _tealium_OO.milestone_percentages[2] && !m3) {
      m3 = true;{event_type:"video",event_name:"milestone",video_milestone:"M:3:"+_tealium_OO.milestone_percentages[2],video_position:pos,video_duration:dur})
      utag.DB("**** 75% viewed****");
    } else if (pct > _tealium_OO.milestone_percentages[3] && !m4) {
      m4 = true;{event_type:"video",event_name:"milestone",video_milestone:"M:4:"+_tealium_OO.milestone_percentages[3],video_position:pos,video_duration:dur})
      utag.DB("**** 90% viewed****");
  extraEvents : function(pEvent,pos,dur){{event_type:"video",event_name:pEvent.type,video_position:pos,video_duration:dur})
  resetMilestones : function(e){
    m25 = false;
    m50 = false;
    m75 = false;
    m90 = false;
  init : function(){
    _tealium_OO.player_object = window[player_object_name];
    //utag.DB("Connecting Tealium with Ooyala object");
    if(typeof _tealium_OO.player_object!="undefined"){
        utag.DB("TEALIUM: Connecting Tealium with Oyala Player - SUCCESS");
        _tealium_OO.eventsAdded = true;
      // If Ooyala object is not defined we will increment the number of tries by 1
      _tealium_OO.init_tries += 1;
      //Stop trying to connect to the Video Player if tried 100 times
        utag.DB("TEALIUM: Cannot connect to Ooyala Video");
      // Calls init function repeatedly either 100 times or Ooyala Object is defined
      setTimeout(function(){_tealium_OO.init()}, 100);

if(typeof _tealium_OO.videoPlayer == "undefined"){
  setTimeout(function(){_tealium_OO.init()}, 300);


Version history
Last update:
‎10-31-2020 08:20 AM
Updated by: