UNPKG

@stereobooster/ganalytics

Version:

A tiny client-side module for tracking with Google Analytics

1 lines 819 B
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.GAnalytics=n()}(this,function(){return function(e,n,t){function o(e,t){var o,i=document,a="https://www.google-analytics.com/collect?v=1";"pageview"!==e||t||(t={dl:location.href,dt:i.title,dr:i.referrer,sr:screen.width+"x"+screen.height,vp:Math.max(i.documentElement.clientWidth,innerWidth||0)+"x"+Math.max(i.documentElement.clientHeight,innerHeight||0)});var c=Object.assign({t:e},n,t,{z:Date.now()});for(o in c)c[o]&&(a+="&"+o+"="+encodeURIComponent(c[o]));(new Image).src=a}return n=Object.assign({tid:e},n,{consent:0},n&&n.consent?{cid:localStorage["ga:user"]=localStorage["ga:user"]||Math.random()+"."+Math.random()}:{uid:"anonymous",aip:1}),t||o("pageview"),{args:n,send:o}}});