1(() => { 2 'use strict'; 3 4 const purpose = 'analytics'; 5 const zaraz = () => window.zaraz; 6 const hasAnalyticsConsent = () => zaraz()?.consent?.get?.(purpose) === true; 7 const serviceSlug = () => { 8 const match = window.location.pathname.match(/^\/servicios\/([^/]+)/u); 9 return match ? match[1] : null; 10 }; 11 const guideSlug = (href) => { 12 const match = String(href || '').match(/^\/guias\/seguros\/([^/?#]+)/u); 13 return match ? match[1] : null; 14 }; 15 const sourceRoute = () => { 16 const pathname = window.location.pathname || '/'; 17 return pathname === '/' ? pathname : pathname.replace(/\/$/u, ''); 18 }; 19 const track = (event, properties) => { 20 if (!hasAnalyticsConsent()) return; 21 zaraz()?.track?.(event, properties); 22 }; 23 24 document.addEventListener('click', (event) => { 25 const target = event.target instanceof Element ? event.target : null; 26 if (!target) return; 27 const cta = target.closest('[data-pf-cta]'); 28 if (cta) { 29 track('pf_cta_click', { 30 service_slug: cta.getAttribute('data-pf-service') || serviceSlug() || 'site-wide', 31 placement: cta.getAttribute('data-pf-placement') || 'unknown', 32 contact_channel: cta.getAttribute('data-pf-contact-channel') || 'whatsapp' 33 }); 34 return; 35 } 36 const faq = target.closest('[data-pf-faq-trigger]'); 37 if (faq) { 38 const index = Number(faq.getAttribute('data-pf-faq-index')); 39 const service = faq.getAttribute('data-pf-service') || serviceSlug(); 40 const details = faq.closest('details'); 41 // A native summary toggles after the click; an already-open detail is closing. 42 if (Number.isInteger(index) && index > 0 && service && !details?.open) { 43 track('pf_faq_open', { service_slug: service, faq_index: index }); 44 } 45 return; 46 } 47 const guide = target.closest('[data-pf-guide-link]'); 48 if (guide) { 49 const slug = guideSlug(guide.getAttribute('href')); 50 if (slug) track('pf_guide_click', { 51 source_route: sourceRoute(), 52 guide_slug: slug, 53 placement: guide.getAttribute('data-pf-placement') || 'content' 54 }); 55 } 56 }); 57})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.