diff --git a/riveted.js b/riveted.js index 46188a8..1cdfc6c 100644 --- a/riveted.js +++ b/riveted.js @@ -50,8 +50,8 @@ var riveted = (function() { googleTagManager = true; } - if ('tracker' in options && typeof options.tracker === 'string') { - universalSendCommand = options.tracker + '.send'; + if ('gaTracker' in options && typeof options.gaTracker === 'string') { + universalSendCommand = options.gaTracker + '.send'; } else { universalSendCommand = 'send'; } diff --git a/riveted.min.js b/riveted.min.js index f22eba9..2c720d3 100644 --- a/riveted.min.js +++ b/riveted.min.js @@ -4,4 +4,4 @@ * Copyright (c) 2015 Rob Flaherty (@robflaherty) * Licensed under the MIT license */ -var riveted=function(){function e(e){e=e||{},p=parseInt(e.reportInterval,10)||5,g=parseInt(e.idleTimeout,10)||30,k=e.gaGlobal||"ga","function"==typeof window[k]&&(w=!0),"undefined"!=typeof _gaq&&"function"==typeof _gaq.push&&(T=!0),"undefined"!=typeof dataLayer&&"function"==typeof dataLayer.push&&(h=!0),I="tracker"in e&&"string"==typeof e.tracker?e.tracker+".send":"send","function"==typeof e.eventHandler&&(s=e.eventHandler),"function"==typeof e.userTimingHandler&&(m=e.userTimingHandler),y="nonInteraction"in e&&(e.nonInteraction===!1||"false"===e.nonInteraction)?!1:!0,t(document,"keydown",f),t(document,"click",f),t(window,"mousemove",n(f,500)),t(window,"scroll",n(f,500)),t(document,"visibilitychange",o),t(document,"webkitvisibilitychange",o)}function n(e,n){var t,i,o,a=null,r=0,u=function(){r=new Date,a=null,o=e.apply(t,i)};return function(){var c=new Date;r||(r=c);var d=n-(c-r);return t=this,i=arguments,0>=d?(clearTimeout(a),a=null,r=c,o=e.apply(t,i)):a||(a=setTimeout(u,d)),o}}function t(e,n,t){e.addEventListener?e.addEventListener(n,t,!1):e.attachEvent?e.attachEvent("on"+n,t):e["on"+n]=t}function i(){clearTimeout(H),r()}function o(){(document.hidden||document.webkitHidden)&&i()}function a(){_+=1,_>0&&_%p===0&&s(_)}function r(){L=!0,clearTimeout(E)}function u(){i(),b=!0}function c(){b=!1}function d(){L=!1,clearTimeout(E),E=setInterval(a,1e3)}function l(){var e=new Date,n=e-D;R=!0,m(n),E=setInterval(a,1e3)}function v(){D=new Date,_=0,R=!1,L=!1,clearTimeout(E),clearTimeout(H)}function f(){b||(R||l(),L&&d(),clearTimeout(H),H=setTimeout(i,1e3*g+100))}var s,m,p,g,y,w,T,I,h,k,R=!1,L=!1,b=!1,_=0,D=new Date,E=null,H=null;return m=function(e){h?dataLayer.push({event:"RivetedTiming",eventCategory:"Riveted",timingVar:"First Interaction",timingValue:e}):(w&&window[k](I,"timing","Riveted","First Interaction",e),T&&_gaq.push(["_trackTiming","Riveted","First Interaction",e,null,100]))},s=function(e){h?dataLayer.push({event:"Riveted",eventCategory:"Riveted",eventAction:"Time Spent",eventLabel:e,eventValue:p,eventNonInteraction:y}):(w&&window[k](I,"event","Riveted","Time Spent",e.toString(),p,{nonInteraction:y}),T&&_gaq.push(["_trackEvent","Riveted","Time Spent",e.toString(),p,y]))},{init:e,trigger:f,setIdle:i,on:c,off:u,reset:v}}(); \ No newline at end of file +var riveted=function(){function e(e){e=e||{},g=parseInt(e.reportInterval,10)||5,p=parseInt(e.idleTimeout,10)||30,k=e.gaGlobal||"ga","function"==typeof window[k]&&(y=!0),"undefined"!=typeof _gaq&&"function"==typeof _gaq.push&&(w=!0),"undefined"!=typeof dataLayer&&"function"==typeof dataLayer.push&&(h=!0),I="gaTracker"in e&&"string"==typeof e.gaTracker?e.gaTracker+".send":"send","function"==typeof e.eventHandler&&(s=e.eventHandler),"function"==typeof e.userTimingHandler&&(m=e.userTimingHandler),T="nonInteraction"in e&&(e.nonInteraction===!1||"false"===e.nonInteraction)?!1:!0,t(document,"keydown",f),t(document,"click",f),t(window,"mousemove",n(f,500)),t(window,"scroll",n(f,500)),t(document,"visibilitychange",a),t(document,"webkitvisibilitychange",a)}function n(e,n){var t,i,a,o=null,r=0,u=function(){r=new Date,o=null,a=e.apply(t,i)};return function(){var c=new Date;r||(r=c);var d=n-(c-r);return t=this,i=arguments,0>=d?(clearTimeout(o),o=null,r=c,a=e.apply(t,i)):o||(o=setTimeout(u,d)),a}}function t(e,n,t){e.addEventListener?e.addEventListener(n,t,!1):e.attachEvent?e.attachEvent("on"+n,t):e["on"+n]=t}function i(){clearTimeout(H),r()}function a(){(document.hidden||document.webkitHidden)&&i()}function o(){_+=1,_>0&&_%g===0&&s(_)}function r(){L=!0,clearTimeout(E)}function u(){i(),b=!0}function c(){b=!1}function d(){L=!1,clearTimeout(E),E=setInterval(o,1e3)}function l(){var e=new Date,n=e-D;R=!0,m(n),E=setInterval(o,1e3)}function v(){D=new Date,_=0,R=!1,L=!1,clearTimeout(E),clearTimeout(H)}function f(){b||(R||l(),L&&d(),clearTimeout(H),H=setTimeout(i,1e3*p+100))}var s,m,g,p,T,y,w,I,h,k,R=!1,L=!1,b=!1,_=0,D=new Date,E=null,H=null;return m=function(e){h?dataLayer.push({event:"RivetedTiming",eventCategory:"Riveted",timingVar:"First Interaction",timingValue:e}):(y&&window[k](I,"timing","Riveted","First Interaction",e),w&&_gaq.push(["_trackTiming","Riveted","First Interaction",e,null,100]))},s=function(e){h?dataLayer.push({event:"Riveted",eventCategory:"Riveted",eventAction:"Time Spent",eventLabel:e,eventValue:g,eventNonInteraction:T}):(y&&window[k](I,"event","Riveted","Time Spent",e.toString(),g,{nonInteraction:T}),w&&_gaq.push(["_trackEvent","Riveted","Time Spent",e.toString(),g,T]))},{init:e,trigger:f,setIdle:i,on:c,off:u,reset:v}}(); \ No newline at end of file diff --git a/test/test.html b/test/test.html index 9d5197a..6f8fc43 100644 --- a/test/test.html +++ b/test/test.html @@ -35,7 +35,7 @@ idleTimeout: 5, nonInteraction: false, //gaGlobal: '__gaTracker', - tracker: 'fooo' + gaTracker: 'fooo' /*eventHandler: function(event) { console.log(event);