- TLC Home Home
- Discussions & Ideas Discussions & Ideas
- Product Guides Product Guides
- Knowledge Base Knowledge Base
- Developer Docs Developer Docs
- Education Education
- Blog TLC Blog
- Support Desk Support Desk
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:
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.
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:
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 utag.link, but there are lines that are commented out that will support the Media Module for Adobe Analytics. The thought behind calling utag.link 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.
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 utag.link 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"){ _tealium_OO.player_object.subscribe(video_events[i],video_events[i],_tealium_OO[video_events[i]]); }else { _tealium_OO.player_object.subscribe(video_events[i],video_events[i],_tealium_OO.extraEvents); } } }, playing:function(e,pos,dur){ pos = _tealium_OO.player_object.getPlayheadTime(); dur = _tealium_OO.player_object.getDuration(); if (!played) { played = true; utag.DB("**** video started ****"); utag.link({event_type:"video",event_name:"play"}) ////s.Media.open(video_name, video_duration, video_player); ////s.Media.play(video_name, 0); //s.Media.track(video_name); } else{ //s.Media.play(video_name, 0); //s.Media.track(video_name); _tealium_OO.pause = false; utag.link({event_type:"video",event_name:"resume",video_position:pos,video_duration:dur}) utag.DB("**** video resumed ****"); } }, paused:function(e,pos,dur){ pos = _tealium_OO.player_object.getPlayheadTime(); dur = _tealium_OO.player_object.getDuration(); //s.Media.stop(video_name, video_position); //s.Media.track(video_name); if(((pos/dur)*100)>90){ _tealium_OO.complete(); }else if(!_tealium_OO.pause){ _tealium_OO.pause = true; utag.link({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); //s.Media.track(video_name); played = false; _tealium_OO.resetMilestones(); utag.link({event_type:"video",event_name:"complete",video_position:pos,video_duration:dur}) 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; utag.link({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; utag.link({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; utag.link({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; utag.link({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){ utag.link({event_type:"video",event_name:pEvent.type,video_position:pos,video_duration:dur}) utag.DB(pEvent); }, 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"){ _tealium_OO.addEvents() utag.DB("TEALIUM: Connecting Tealium with Oyala Player - SUCCESS"); _tealium_OO.eventsAdded = true; return; }else{ // 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 if(_tealium_OO.init_tries>100){ utag.DB("TEALIUM: Cannot connect to Ooyala Video"); return; } // 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); }
Copyright All Rights Reserved © 2008-2021