mirror of
https://github.com/plausible/analytics.git
synced 2024-11-30 00:58:54 +03:00
199206babc
* added the first version of dimensions extension * finished dimensions script extension + updated tracking to use it * script variants build
1 line
1.1 KiB
JavaScript
1 line
1.1 KiB
JavaScript
!function(){"use strict";var e,t,n,o=window.location,l=window.document,u=l.getElementById("plausible"),w=u.getAttribute("data-api")||(e=u.src.split("/"),t=e[0],n=e[2],t+"//"+n+"/api/event");function i(e,t){if(!(window._phantom||window.__nightmare||window.navigator.webdriver||window.Cypress)){try{if("true"===window.localStorage.plausible_ignore)return void console.warn("Ignoring Event: localStorage flag")}catch(e){}var n={};n.n=e,n.u=t&&t.u?t.u:o.href,n.d=u.getAttribute("data-domain"),n.r=l.referrer||null,n.w=window.innerWidth,t&&t.meta&&(n.m=JSON.stringify(t.meta)),t&&t.props&&(n.p=t.props);var i=u.getAttributeNames().filter(function(e){return"event-"===e.substring(0,6)}),a=n.p||{};i.forEach(function(e){var t=e.replace("event-",""),n=u.getAttribute(e);a[t]=a[t]||n}),n.p=a,n.h=1;var r=new XMLHttpRequest;r.open("POST",w,!0),r.setRequestHeader("Content-Type","text/plain"),r.send(JSON.stringify(n)),r.onreadystatechange=function(){4===r.readyState&&t&&t.callback&&t.callback()}}}var a=window.plausible&&window.plausible.q||[];window.plausible=i;for(var r=0;r<a.length;r++)i.apply(this,a[r])}(); |