/*! * @preserve * jquery.scrolldepth.js | v0.9.1m * Copyright (c) 2016 Rob Flaherty (@robflaherty) * Licensed under the MIT and GPL licenses. */ !function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(e){"use strict";var n,t,o,i,r,l={minHeight:0,elements:[],percentage:!0,userTiming:!0,pixelDepth:!0,nonInteraction:!0,gaGlobal:!1,gtmOverride:!1},a=e(window),c=[],p=!1,h=0;e.scrollDepth=function(u){var g=+new Date;function s(e,l,a,c){r&&!i?(r({event:"ScrollDistance",eventCategory:"Scroll Depth",eventAction:e,eventLabel:l,eventValue:1,eventNonInteraction:u.nonInteraction}),u.pixelDepth&&arguments.length>2&&a>h&&(h=a,r({event:"ScrollDistance",eventCategory:"Scroll Depth",eventAction:"Pixel Depth",eventLabel:f(a),eventValue:1,eventNonInteraction:u.nonInteraction})),u.userTiming&&arguments.length>3&&r({event:"ScrollTiming",eventCategory:"Scroll Depth",eventAction:e,eventLabel:l,eventTiming:c})):(n?(window[o]("send","event","Scroll Depth",e,l,1,{nonInteraction:u.nonInteraction}),u.pixelDepth&&arguments.length>2&&a>h&&(h=a,window[o]("send","event","Scroll Depth","Pixel Depth",f(a),1,{nonInteraction:u.nonInteraction})),u.userTiming&&arguments.length>3&&window[o]("send","timing","Scroll Depth",e,c,l)):i&&(window[o]("event",e,{event_category:"Scroll Depth",event_label:l,non_interaction:u.nonInteraction}),u.pixelDepth&&arguments.length>2&&a>h&&(h=a,window[o]("event","Scroll Depth",{event_category:"Pixel Depth",event_label:f(a),non_interaction:u.nonInteraction})),u.userTiming&&arguments.length>3&&window[o]("event",c,{event_category:"Pixel Depth",event_label:l,non_interaction:u.nonInteraction})),t&&(_gaq.push(["_trackEvent","Scroll Depth",e,l,1,u.nonInteraction]),u.pixelDepth&&arguments.length>2&&a>h&&(h=a,_gaq.push(["_trackEvent","Scroll Depth","Pixel Depth",f(a),1,u.nonInteraction])),u.userTiming&&arguments.length>3&&_gaq.push(["_trackTiming","Scroll Depth",e,c,l,100])))}function f(e){return(250*Math.floor(e/250)).toString()}function v(){var n,t,o,i,r,l,h,f;p=!0,a.on("scroll.scrollDepth",(n=function(){var n=e(document).height(),t=window.innerHeight?window.innerHeight:a.height(),o=a.scrollTop()+t,i=function(e){return{"25%":parseInt(.25*e,10),"50%":parseInt(.5*e,10),"75%":parseInt(.75*e,10),"100%":e-5}}(n),r=+new Date-g;if(c.length>=u.elements.length+(u.percentage?4:0))return a.off("scroll.scrollDepth"),void(p=!1);u.elements&&function(n,t,o){e.each(n,function(n,i){-1===e.inArray(i,c)&&e(i).length&&t>=e(i).offset().top&&(s("Elements",i,t,o),c.push(i))})}(u.elements,o,r),u.percentage&&function(n,t,o){e.each(n,function(n,i){-1===e.inArray(n,c)&&t>=i&&(s("Percentage",n,t,o),c.push(n))})}(i,o,r)},t=500,l=null,h=0,f=function(){h=new Date,l=null,r=n.apply(o,i)},function(){var e=new Date;h||(h=e);var a=t-(e-h);return o=this,i=arguments,a<=0?(clearTimeout(l),l=null,h=e,r=n.apply(o,i)):l||(l=setTimeout(f,a)),r}))}u=e.extend({},l,u),e(document).height()