window.dataLayer = window.dataLayer || []; function gtag(){ dataLayer.push(arguments); } gtag('js', new Date()); gtag('config', 'G-0FRX79HBL7',{ 'cookie_domain': 'auto', }); const targetClasses = { '.medicationguide':'Medication Guide', '.medicationguide1':'Medication Guide', '.prescribinginfo':'Prescribing Info', '.prescribinginfo1':'Prescribing Info', '.prescribinginfo2':'Prescribing Info', '.fdaLink':'FDA Link', '.privacyPolicy':'Privacy Policy', '.termsOfUse':'Terms of Use', '.cookiePolicy':'Cookie Policy', '.contactUs':'Contact Us', '.remsOverview':'REMS Overview', '.remsOverview1':'REMS Overview', '.educationProgram':'Education Program', '.educationProgram1':'Education Program', '.hcpAssessment':'HCP Assessment', '.hcpEnrollmentForm':'HCP Enrollment Form', '.patientEnrollmentForm':'Patient Enrollment Form', '.patientGuide':'Patient Guide', '.patientGuide1':'Patient Guide', '.patientMonitoringForm':'Patient Monitoring Form', '.pharmacyEnrollmentForm':'Pharmacy Enrollment Form', '.loginAttempts':'Login Attempts', '.npiAttempts':'NPI Search Attempts' }; document.onreadystatechange = function () { if (document.readyState === 'complete') { // function call to track the new contents post SPA journey buttonAndLinkClick(); } } function buttonAndLinkClick() { Object.entries(targetClasses).forEach(([selector, eventName]) => { const el = document.querySelector(selector); if(el){ el.addEventListener('click', (e) => { // gtag function call to send event hit to Google Analytics along with the variables gtag('event', eventName); }); } }); } let lastUrl = document.title; new MutationObserver(()=>{ const currentUrl = document.title; if(currentUrl !== lastUrl){ lastUrl=currentUrl; buttonAndLinkClick(); } }).observe(document.body, {subtree:true,childList:true});