(function(){ var W=window,D=document,L=W.location; var fn=function(){return W.gtag||W.__gtagTracker;}; var fired={}; function send(name,params){var g=fn();if(typeof g!=='function')return;try{g('event',name,params);}catch(e){}} function onScroll(){ var doc=D.documentElement; var scrolled=W.pageYOffset||doc.scrollTop; var height=(doc.scrollHeight-doc.clientHeight)||1; var pct=Math.round((scrolled/height)*100); [25,50,75,100].forEach(function(m){ if(pct>=m && !fired['d'+m]){ fired['d'+m]=true; send('scroll_depth',{depth_percent:m,page_path:L.pathname}); } }); } W.addEventListener('scroll',onScroll,{passive:true}); onScroll(); if('IntersectionObserver' in W && D.documentElement.closest){ var all=D.querySelectorAll('h2,h3'); var heads=[]; for(var i=0;i-1){t=t.split(' ').join(' ');} t=t.trim().slice(0,60); if(t && !seen[t]){ seen[t]=true; send('section_reached',{section_title:t,page_path:L.pathname}); } } }); },{threshold:0.3}); heads.forEach(function(h){obs.observe(h);}); } })();