const ga4Script = document.createElement('script'); ga4Script.onload = function () { window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-GG2W601R34', { cookie_flags: 'max-age=7200;secure;samesite=none' }); var AMFGTracker = null; function createTracker(opt_clientId) { if (AMFGTracker) { return; } if (opt_clientId) { gtag('set', { client_id: opt_clientId }); } AMFGTracker = function(data) { if (data.hitType === 'event') { // page_view will be tracked automatically by GA4 gtag('event', data.eventCategory, { event_action: data.eventAction, event_label: data.eventLabel, ...data }); } }; window.AMFGTracker = AMFGTracker } window.addEventListener('message', function(event) { // Ignores messages from untrusted domains. var liveRegex = /^https:\/\/[a-zA-Z.-]+\.amfg\.ai\/client-app.*$/; var stageRegex = /^https:\/\/rpp-(staging|testing)\.com\/client-app.*$/; var isLive = liveRegex.test(event.origin); var isStage = stageRegex.test(event.origin); if (!isLive && !isStage) { return; } createTracker(event.data); }); setTimeout(createTracker, 1000); }; ga4Script.async = 1; ga4Script.src = 'https://www.googletagmanager.com/gtag/js?id=G-GG2W601R34'; const node = document.getElementsByTagName('script')[0]; if (node) { node.parentNode.insertBefore(ga4Script, node) }