// GTM link event listener document.querySelector("body").addEventListener('click', function(e) { var anchor = e.target.closest('a'); if (anchor !== null) { document.body.dispatchEvent(new CustomEvent('gtmlinkclick', { bubbles: true, composed: true, detail : anchor })); } var buttonPrimary = e.target.closest('.rp-button-primary'); if (buttonPrimary !== null) { document.body.dispatchEvent(new CustomEvent('gtmlinkclick', { bubbles: true, composed: true, detail : buttonPrimary })); } var buttonSecondary = e.target.closest('.rp-button-secondary'); if (buttonSecondary !== null) { document.body.dispatchEvent(new CustomEvent('gtmlinkclick', { bubbles: true, composed: true, detail : buttonSecondary })); } }, false); document.onreadystatechange = function () { if (document.readyState === 'complete') { // function call to track the new contents post SPA journey window.addEventListener('calendarcomponentisready', (event) => { const calendarConfig = event?.detail; if (calendarConfig) { const instance = flatpickr(".rp-calendar", calendarConfig); instance.config.onChange.push(function(dateobj, datestr) { document.body.dispatchEvent(new CustomEvent('calendarcomponentonchange', { bubbles: true, composed: true, detail : { dateobj, datestr }})); }); } }); } }