| 1 |
!function(e){var n;function t(){if("undefined"!=typeof gtag||void 0!==window.dataLayer&&"function"==typeof window.dataLayer.push)e.scrollDepth();else{const n=50;let t=0;const o=setInterval(function(){t++,("undefined"!=typeof gtag||void 0!==window.dataLayer&&"function"==typeof window.dataLayer.push||t>=n)&&(clearInterval(o),e.scrollDepth())},100)}}n=function(e){"use strict";const n={percentage:!0},t=e(window);let o=[],i=!1,l=0;return e.scrollDepth=function(r){const a=+new Date;function c(e,n,t,o){if("undefined"!=typeof gtag){gtag("event","scroll_depth",{wpa_category:"Analytify Scroll Depth",wpa_percentage:n,non_interaction:!0});const t=o||+new Date-a;gtag("event","timing_complete",{event_category:"Analytify Scroll Depth",event_label:e+" - "+n+"%",value:t,non_interaction:!0})}}function f(){i=!0,t.on("scroll.scrollDepth",function(e,n){let t=null,o=0;return function(){const i=this,l=arguments,r=new Date;o||(o=r);const a=n-(r-o);a<=0?(clearTimeout(t),t=null,o=r,e.apply(i,l)):t||(t=setTimeout(function(){o=new Date,t=null,e.apply(i,l)},a))}}(function(){const n=e(document).height(),i=window.innerHeight?window.innerHeight:t.height(),l=t.scrollTop()+i,r=function(e){return{25:parseInt(.25*e,10),50:parseInt(.5*e,10),75:parseInt(.75*e,10),100:e-5}}(n);!function(n,t,i){e.each(n,function(n,l){-1===e.inArray(n,o)&&t>=l&&(c("undefined"!=typeof analytifyScroll&&analytifyScroll.permalink?analytifyScroll.permalink:window.location.href,n,0,i),o.push(n))})}(r,l,+new Date-a)},500))}r=e.extend({},n,r),e.scrollDepth.reset=function(){o=[],l=0,t.off("scroll.scrollDepth"),f()},e.scrollDepth.addElements=function(n){void 0!==n&&e.isArray(n)&&(e.merge(r.elements,n),i||f())},e.scrollDepth.removeElements=function(n){void 0!==n&&e.isArray(n)&&e.each(n,function(n,t){const i=e.inArray(t,r.elements),l=e.inArray(t,o);-1!=i&&r.elements.splice(i,1),-1!=l&&o.splice(l,1)})},function(){f();const n=e(document).height();if((window.innerHeight?window.innerHeight:t.height())>=n){const n=+new Date-a,t="undefined"!=typeof analytifyScroll&&analytifyScroll.permalink?analytifyScroll.permalink:window.location.href;-1===e.inArray("100",o)&&(c(t,"100",0,n),o.push("100"))}}()},e.scrollDepth},"function"==typeof define&&define.amd?define(["jquery"],n):"object"==typeof module&&module.exports?module.exports=n(require("jquery")):n(jQuery),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):t()}(jQuery); |