|
document.addEventListener('DOMContentLoaded', () => {
setTimeout(initGTM, 2500);
});
document.addEventListener('scroll', initGTMOnEvent);
document.addEventListener('mousemove', initGTMOnEvent);
document.addEventListener('touchstart', initGTMOnEvent);
function initGTMOnEvent(event) {
initGTM();
event.currentTarget.removeEventListener(event.type, initGTMOnEvent);
}
function initGTM() {
if (window.gtmDidInit) {
return false;
}
window.gtmDidInit = true;
const script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.onload = () => {
dataLayer.push({ event: 'gtm.js', 'gtm.start': new Date().getTime(), 'gtm.uniqueEventId': 0 });
};
script.src = 'https://www.googletagmanager.com/gtm.js?id=G-PPWHHVFVQQ';
document.head.appendChild(script);
|