Hi
I am tracking YT video consumption on my site using the You Tube IFrame Player API and deployed the code using DTM
- My set up
I did not enable Video Reporting on Adobe Analytics as the whole Solutions Variable option doesn't make sense to me.. I can not see or understand how the mapping is done. So i enabled the variables and events that I needed for my implementation in AA.
2. Youtube link on site is appended with &enablejsapi=1 and has an ID
3. Added the adobe media library
4. Added Youtube tracking module
5. Added Youtube iFrame Javascript API
6. Added Adobe Analytics media module configuration
All looks fine but when i run the video i get the following error on the debugger console - Uncaught TypeError: i.Media.open is not a function
i.Media.open(r,o,e),i.Media.play(r,s)):(s=Math.floor(t.target.getCurrentTime()),i.Media.play(r,s))}if(t.data==YT.PlayerState.PAUSED){var e="YouTube",n=t.target.getVideoData().title,a=t.target.getVideoData().video_id,r=e+"|"+a+"|"+n;s=Math.floor(t.target.getCurrentTime()),i.Media.stop(r,s)}if(t.data==YT.PlayerState.BUFFERING){var e="YouTube",n=t.target.getVideoData().title,a=t.target.getVideoData().video_id,r=e+"|"+a+"|"+n;s=Math.floor(t.target.getCurrentTime()),i.Media.stop(r,s)}if(t.data==YT.PlayerState.ENDED){var e="YouTube",n=t.target.getVideoData().title,a=t.target.getVideoData().video_id,r=e+"|"+a+"|"+n;s=0,i.Media.stop(r,s),i.Media.close(r)}}t.onYouTubeIframeAPIReady=function(){var t=new Array;t.push("player-tag-tracking");var e=new Array;for(x=0;x<t.length;x++)e[x]=new YT.Player(t[x],{events:{onStateChange:n}})};var a=e.createElement("script");a.src="https://www.youtube.com/iframe_api";var r=e.getElementsByTagName("script")[0];r.parentNode.insertBefore(a,r),i.usePlugins=!0,i.doPlugins=function(t){},i.enableVideoTracking=!0,i.enableVideoTracking&&(i.loadModule("Media"),i.Media.autoTrack=!1,i.Media.playerName="YouTube",i.Media.segmentByMilestones=!0,i.Media.trackMilestones="25,50,75",i.Media.trackUsingContextData=!0,i.Media.contextDataMapping={"a.contentType":"eVar32","a.media.name":"eVar31,prop31","a.media.segment":"eVar33","a.media.view":"event31","a.media.complete":"event35","a.media.segmentView":"event36","a.media.timePlayed":"event37","a.media.milestones":{25:"event32",50:"event33",75:"event34"}},i.Media.trackVars="events,eVar31,eVar32,eVar33,prop31",i.Media.trackEvents="event31,event32,event33,event34,event35,event36,event37"),i.getPreviousValue=new Function("v","c","el","var s=this,t=new Date,i,j,r='';t.setTime(t.getTime()+1800000);if(el){if(s.events){i=s.split(el,',');j=s.split(s.events,',');for(x in i){for(y in j){if(i[x]==j[y]){if(s.c_r(c)) r=s.c_r(c);v?s.c_w(c,v,t):s.c_w(c,'no value',t);return r}}}}}else{if(s.c_r(c)) r=s.c_r(c);v?s.c_w(c,v,t):s.c_w(c,'no value',t);return r}"),i.split=new Function("l","d","var i,x=0,a=new Array;while(l){i=l.indexOf(d);i=i>-1?i:l.length;a[x++]=l.substring(0,i);l=l.substring(i+d.length);}return a"),i.getPercentPageViewed=new Function("n","var s=this,W=window,EL=W.addEventListener,AE=W.attachEvent,E=['load','unload','scroll','resize','zoom','keyup','mouseup','touchend','orientationchange','pan'];W.s_Obj=s;s_PPVid=(n=='-'?s.pageName:n)||s.pageName||location.href;if(!W.s_PPVevent){s.s_PPVg=function(n,r){var k='s_ppv',p=k+'l',c=s.c_r(n||r?k:p),a=c.indexOf(',')>-1?c.split(',',10):[''],l=a.length,i;a[0]=unescape(a[0]);r=r||(n&&n!=a[0])||0;a.length=10;if(typeof a[0]!='string')a[0]='';for(i=1;i<10;i++)a[i]=!r&&i<l?parseInt(a[i])||0:0;if(l<10||typeof a[9]!='string')a[9]='';if(r){s.c_w(p,c);s.c_w(k,'?')}return a};W.s_PPVevent=function(e){var W=window,D=document,B=D.body,E=D.documentElement,S=window.screen||0,Ho='offsetHeight',Hs='scrollHeight',Ts='scrollTop',Wc='clientWidth',Hc='clientHeight',C=100,M=Math,J='object',N='number',s=W.s_Obj||W.s||0;e=e&&typeof e==J?e.type||'':'';if(!e.indexOf('on'))e=e.substring(2);s_PPVi=W.s_PPVi||0;if(W.s_PPVt&&!e){clearTimeout(s_PPVt);s_PPVt=0;if(s_PPVi<2)s_PPVi++}if(typeof s==J){var h=M.max(B[Hs]||E[Hs],B[Ho]||E[Ho],B[Hc]||E[Hc]),X=W.innerWidth||E[Wc]||B[Wc]||0,Y=W.innerHeight||E[Hc]||B[Hc]||0,x=S?S.width:0,y=S?S.height:0,r=M.round(C*(W.devicePixelRatio||1))/C,b=(D.pageYOffset||E[Ts]||B[Ts]||0)+Y,p=h>0&&b>0?M.round(C*b/h):0,O=W.orientation,o=!isNaN(O)?M.abs(o)%180:Y>X?0:90,L=e=='load'||s_PPVi<1,a=s.s_PPVg(s_PPVid,L),V=function(i,v,f,n){i=parseInt(typeof a==J&&a.length>i?a[i]:'0')||0;v=typeof v!=N?i:v;v=f||v>i?v:i;return n?v:v>C?C:v<0?0:v};if(new RegExp('(iPod|iPad|iPhone)').exec(navigator.userAgent||'')&&o){o=x;x=y;y=o}o=o?'P':'L';a[9]=L?'':a[9].substring(0,1);s.c_w('s_ppv',escape(W.s_PPVid)+','+V(1,p,L)+','+(L||!V(2)?p:V(2))+','+V(3,b,L,1)+','+X+','+Y+','+x+','+y+','+r+','+a[9]+(a[9]==o?'':o))}if(!W.s_PPVt&&e!='unload')W.s_PPVt=setTimeout(W.s_PPVevent,333)};for(var f=W.s_PPVevent,i=0;i<E.length;i++)if(EL)EL(E[i],f,false);else if(AE)AE('on'+E[i],f);f()};var a=s.s_PPVg();return!n||n=='-'?a[1]:a"),i.getQueryParam=new Function("p","d","u","var s=this,v='',i,t;d=d?d:'';u=u?u:(s.pageURL?s.pageURL:s.wd.location);if(u=='f')u=s.gtfs().location;while(p){i=p.indexOf(',');i=i<0?p.length:i;t=s.p_gpv(p.substring(0,i),u+'');if(t){t=t.indexOf('#')>-1?t.substring(0,t.indexOf('#')):t;}if(t)v+=v?d+t:t;p=p.substring(i==p.length?i:i+1)}return v"),i.p_gpv=new Function("k","u","var s=this,v='',i=u.indexOf('?'),q;if(k&&i>-1){q=u.substring(i+1);v=s.pt(q,'&','p_gvf',k)}return v"),i.p_gvf=new Function("t","k","if(t){var s=this,i=t.indexOf('='),p=i<0?t:t.substring(0,i),v=i<0?'True':t.substring(i+1);if(p.toLowerCase()==k.toLowerCase())return s.epa(v)}return ''");var o={pl:[]};o.p=function(){var n=function(t,e){var i=t.indexOf("?"),n=t.indexOf("#");if(0>i)return"";var a=t.substr(i+1);n>0&&(a=t.substring(i+1,n));var r,o=a.split("&");for(r=0;r<o.length;r++){var s=o[r].split("=");if(s[0]=unescape(s[0]),s[0]===e){if(s[1]=unescape(s[1]),s[1].indexOf('"')>-1){var c=/"/g;s[1]=s[1].replace(c,'\\"')}if(s[1].indexOf("+")>-1){var u=/\+/g;s[1]=s[1].replace(u," ")}return s[1]}}return""},a=function(e,i,n){"object"==typeof e&&null!==e&&(e.attachEvent?(e["e"+i+n]=n,e[i+n]=function(){e["e"+i+n](t.event)},e.attachEvent("on"+i,e[i+n])):e.addEventListener(i,n,!1))};this.p=null,this.id="",this.op=!1,this.pl=!1,this.po=0,this.du=0,this.bl=0,this.tp=!1,this.i=function(n){var r=0;if("object"!=typeof i&&(r=3),!r&&(this.p=e.getElementById(n),this.p)){n.match(/^[a-z0-9]+$/i)?(t["adyttsc"+n]=function(t){o.pl[n].st(t)},this.p.addEventListener("onStateChange","adyttsc"+n)):this.p.addEventListener("onStateChange","adytt.pl['"+n+"'].st");var s=this;a(t,"unload",function(t){s.op&&"function"==typeof s.sc&&s.sc(s.po,!0)})}},this.sc=function(t,e){this.pl&&(i.Media.stop(this.id,t),this.pl=!1,this.tp=!1),e&&this.op&&(i.Media.close(this.id),this.op=!1,clearInterval(this.tf))},this.st=function(t){switch(this.tp=!1,t){case 0:this.sc(this.du,!0);break;case 1:if(this.du=Math.floor(this.p.getDuration()),!this.op){var e=this.p.getVideoUrl();this.id="YT|"+n(e,"v"),"function"==typeof o.getID&&(this.id=o.getID({url:e})),i.Media.open(this.id,this.du,"YouTube Embedded Player",{id:this.id});var a=this;this.tf=setInterval(function(){a.ti()},500),this.op=!0}this.tp=!0;break;case 2:this.sc(Math.floor(this.po),!1);break;case 3:this.bl=this.p.getVideoBytesLoaded(),this.po=this.p.getCurrentTime(),-1===this.bl?this.sc(Math.floor(this.po),!0):this.sc(Math.floor(this.po),!1);break;case-1:break;case 5:this.sc(Math.floor(this.po),!1)}},this.ti=function(){e.getElementById(this.p.id)?this.p&&(1===this.p.getPlayerState()||this.tp)&&(this.po=this.p.getCurrentTime(),this.bl=this.p.getVideoBytesLoaded(),this.tp&&this.bl>0&&!this.pl&&
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Are you using the Media Module code that matches your s_code/AppMeasurement version? Typically, when you download your code library from Code Manager, there is a Media Module that's included in the download package. We've seen issues when users try to use an older version of the Media Module with an updated s_code/AppMeasurement library.
Additionally, our video team is encouraging all customers to move to Video Heartbeat tracking. The Media Module is considered legacy at this point. Please see the documentation here.
Thanks,
Jantzen
Views
Replies
Total Likes
Hi,
Are you using the Media Module code that matches your s_code/AppMeasurement version? Typically, when you download your code library from Code Manager, there is a Media Module that's included in the download package. We've seen issues when users try to use an older version of the Media Module with an updated s_code/AppMeasurement library.
Additionally, our video team is encouraging all customers to move to Video Heartbeat tracking. The Media Module is considered legacy at this point. Please see the documentation here.
Thanks,
Jantzen
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies