// gtag basic snippet code do not change window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag('js', new Date()); gtag('config', 'GTM-M2R7LHQW', { 'cookie_domain': 'auto', }); document.onreadystatechange = function () { if (document.readyState === 'complete') { // function call to track the new contents post SPA journey buttonAndLinkClick(); } } function buttonAndLinkClick() { let matches = document.querySelectorAll('.button_class'); if (matches) { matches.forEach(element => { element.addEventListener('click', (targetElement) => { // gtag function call to send event hit to Google Analytics along with the variables gtag('event', 'custom_click_Text_Trigger', { element: targetElement, elementId: targetElement.id || '', elementClasses: targetElement.className || '', elementUrl: targetElement.href || targetElement.action || '', elementTarget: targetElement.target || '', elementText: targetElement.innerText }); }); }); } }