UNPKG

gtag-ga

Version:

Google Analytics 4 (gtag.js) for NodeJS ES Module. Simple installation to send page views or event tracking.

1 lines 576 B
export default class t{static initializeGtag(e,a){if("undefined"==typeof window)throw new Error("'window' object not found, make sure you're using initialize in the right place.");if(void 0!==window.gtag)return;const i=document.createElement("script");i.async=!0,i.src=`https://www.googletagmanager.com/gtag/js?id=${e}`,document.head.insertBefore(i,document.head.firstChild),window.dataLayer=window.dataLayer||[],t.gtag("js",new Date),t.gtag("config",e,a)}static gtag(...t){window.dataLayer.push(t)}}export{t as GtagGA};export const{initializeGtag:initializeGtag,gtag:gtag}=t;