// global.js — LGPD + Meta Pixel + Google Ads Ready (function(){ // ========================== // CONFIGURAÇÕES // ========================== // COLOQUE AQUI SEUS IDS const META_PIXEL_ID = "COLE_SEU_PIXEL_ID_AQUI"; const GOOGLE_ADS_ID = "COLE_SEU_GOOGLE_ADS_ID_AQUI"; // ========================== // FUNÇÃO CARREGAR META PIXEL // ========================== function loadMetaPixel(){ !function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if(!f._fbq)f._fbq=n; n.push=n;n.loaded=!0;n.version='2.0'; n.queue=[];t=b.createElement(e); t.async=!0; t.src=v; s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s)} (window, document,'script', 'https://connect.facebook.net/en_US/fbevents.js'); fbq('init', META_PIXEL_ID); fbq('track', 'PageView'); } // ========================== // FUNÇÃO CARREGAR GOOGLE ADS // ========================== function loadGoogleAds(){ const script = document.createElement("script"); script.src = `https://www.googletagmanager.com/gtag/js?id=${GOOGLE_ADS_ID}`; script.async = true; document.head.appendChild(script); window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} window.gtag = gtag; gtag('js', new Date()); gtag('config', GOOGLE_ADS_ID); } // ========================== // VERIFICAR CONSENTIMENTO // ========================== function loadTracking(){ loadMetaPixel(); loadGoogleAds(); } // ========================== // BANNER LGPD // ========================== if(!localStorage.getItem("cookiesConsent")){ const banner = document.createElement("div"); banner.innerHTML = `
Utilizamos cookies para melhorar sua experiência conforme nossa Política de Privacidade .
`; document.body.appendChild(banner); document.getElementById("acceptCookies").onclick=function(){ localStorage.setItem("cookiesConsent","accepted"); banner.remove(); loadTracking(); }; document.getElementById("rejectCookies").onclick=function(){ localStorage.setItem("cookiesConsent","rejected"); banner.remove(); }; } // ========================== // SE JÁ ACEITOU ANTES // ========================== if(localStorage.getItem("cookiesConsent")==="accepted"){ loadTracking(); } // ========================== // FORCE HTTPS EXTRA // ========================== if(location.protocol==="http:"){ location.replace("https://"+location.hostname+location.pathname); } })();