/** KONVERLY Replacement via UTM Parameters - Place in HEADER */ (function () { if (window.__hasRunUTMReplace) return; window.__hasRunUTMReplace = true; function runUTMReplace() { const container = document.getElementById("pageLayoutContent"); if (!container) { console.warn("UTM Replace: container not found"); return; } const params = new URLSearchParams(window.location.search); // Step 1: Replace [[token]] in innerHTML let html = container.innerHTML; const matches = html.match(/\[\[(.*?)\]\]/g) || []; matches.forEach(fullMatch => { const token = fullMatch.slice(2, -2); const raw = params.get(token); const value = raw ? decodeURIComponent(raw) : ''; html = html.replaceAll(fullMatch, value); console.log(`Replacing ${fullMatch} in innerHTML with "${value}"`); }); container.innerHTML = html; // Step 2: Replace [[token]] in href, src, action attributes const elements = container.querySelectorAll('[href], [src], [action]'); elements.forEach(el => { ['href', 'src', 'action'].forEach(attr => { if (!el.hasAttribute(attr)) return; let attrValue = el.getAttribute(attr); const attrMatches = attrValue.match(/\[\[(.*?)\]\]/g) || []; attrMatches.forEach(fullMatch => { const token = fullMatch.slice(2, -2); const raw = params.get(token); const value = raw ? decodeURIComponent(raw) : ''; attrValue = attrValue.replaceAll(fullMatch, value); console.log(`Replacing ${fullMatch} in ${attr} with "${value}"`); }); el.setAttribute(attr, attrValue); }); }); } // Run when DOM is ready if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', runUTMReplace); } else { runUTMReplace(); } })();

Video Loading ...