// gtag basic snippet code do not change window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag('js', new Date()); gtag('config', 'G-K873W4YZM6', { 'cookie_domain': 'auto', }); document.onreadystatechange = function () { if (document.readyState === 'complete') { // function call to track the new contents post SPA journey buttonAndLinkClick(); } } function buttonAndLinkClick() { document.querySelector('.commerce_product_details-addToCartButton_addToCartButton').addEventListener('click', (e) => { // gtag function call to send event hit to Google Analytics along with the variables gtag('event', 'CTA Button', { 'event_category': 'link_button_click', 'event_label': 'Submit button clicked' }); }); // query selector to capture the anchor element i.e with class download_link document.querySelector('.download_link').addEventListener('click', (e) => { //gtag function call to send event hit to Google Analytics along with the variables gtag('event', 'Link Button', { 'event_category': 'link_button_click', 'event_label': 'Download link clicked' }); }); }