Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mattiasaxelsson/f0381876744b1a66de3577b9dbaf0578 to your computer and use it in GitHub Desktop.
Save mattiasaxelsson/f0381876744b1a66de3577b9dbaf0578 to your computer and use it in GitHub Desktop.
Minimal Analytics Snippet Compressed
!function(s,u){function v(){return e.cid||(e.cid=Math.random().toString(36)),e.cid}function i(e,t,o,n,i,r,a){var c,d="https://www.google-analytics.com/collect",l=function(e){var t=[];for(var o in e)e.hasOwnProperty(o)&&void 0!==e[o]&&t.push(g(o)+"="+g(e[o]));return t.join("&")}({v:"1",ds:"web",aip:u.anonymizeIp?1:void 0,tid:"XX-XXXXXXXXX-X",cid:v(),t:e||"pageview",sd:u.colorDepth&&screen.colorDepth?screen.colorDepth+"-bits":void 0,dr:p.referrer||void 0,dt:p.title,dl:p.location.origin+p.location.pathname+p.location.search,ul:u.language?(h.language||"").toLowerCase():void 0,de:u.characterSet?p.characterSet:void 0,sr:u.screenSize?(s.screen||{}).width+"x"+(s.screen||{}).height:void 0,vp:u.screenSize&&s.visualViewport?(s.visualViewport||{}).width+"x"+(s.visualViewport||{}).height:void 0,ec:t||void 0,ea:o||void 0,el:n||void 0,ev:i||void 0,exd:r||void 0,exf:void 0!==a&&0==!!a?0:void 0});h.sendBeacon?h.sendBeacon(d,l):((c=new XMLHttpRequest).open("POST",d,!0),c.send(l))}var t=s.history,p=document,h=navigator||{},e=localStorage,g=encodeURIComponent,o=t.pushState;t.pushState=function(e){return"function"==typeof t.onpushstate&&t.onpushstate({state:e}),setTimeout(i,u.delay||10),o.apply(t,arguments)},i(),s.ma={trackEvent:function(e,t,o,n){return i("event",e,t,o,n)},trackException:function(e,t){return i("exception",null,null,null,null,e,t)}}}(window,{anonymizeIp:!0,colorDepth:!0,characterSet:!0,screenSize:!0,language:!0});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment