404

404

Looks like you took a wrong turn.

Let’s take you back where things make sense.

Looks like you took a wrong turn.

Let’s take you back where things make sense.

dentro del const pTexts = Array.from(linkEl.querySelectorAll('p')) .map(n => (n.textContent || '').trim()) .filter(Boolean); // 2) fallback: texto visible completo del pTexts.push((linkEl.innerText || linkEl.textContent || '').trim()); // Buscar match contra cualquier candidato let eventName = null; let rawMatched = ''; outer: for (const candidate of pTexts) { const t = norm(candidate); for (const key in targets) { if (t.includes(key)) { eventName = targets[key]; rawMatched = candidate; break outer; } } } if (!eventName) return; const isLink = !!linkEl.href; const opensNewTab = isLink && linkEl.target && linkEl.target !== '_self'; const params = { button_text: rawMatched, link_url: isLink ? linkEl.href : null, location: window.location.pathname }; if (isLink && !opensNewTab) { // misma pestaña: garantizamos envío antes de navegar e.preventDefault(); let navigated = false; const go = () => { if (!navigated) { navigated = true; window.location.href = linkEl.href; } }; gtag('event', eventName, { ...params, event_callback: go }); setTimeout(go, 500); // fallback } else { // nueva pestaña o sin href gtag('event', eventName, params); } console.log('[GA] sent:', eventName, params, 'candidates:', pTexts); }, true); })();