window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); document.addEventListener('analyticsSupport', function(e) { //get the details of the event and parse into an object let detail = JSON.parse(JSON.stringify(e.detail)); console.log('from markup'+JSON.stringify(detail)); //set the gtag config with the proper G- measurement ID and //the detail object containing the user properties and user id gtag('config', 'G-1KGQHDT3HL', detail); });