var propertyId = 'G-ZJ7LM3KGPN'; var elementName = 'script'; var script = document.createElement(elementName); script.src = 'https://www.googletagmanager.com/gtag/js?id=' + propertyId; script.async = true; var firstScript = document.getElementsByTagName(elementName)[0]; firstScript.parentNode.insertBefore(script, firstScript); window.dataLayer = window.dataLayer || []; function gtag() {dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', propertyId); window.gtag = gtag;