@@ -21,8 +21,8 @@ interface Props {
2121// que en /en, sin depender de un segmento dinámico de ruta.
2222const { title, description, pageName, lang = ' es' } = Astro .props ;
2323
24+ const googleAnalyticsId = ' G-7XZMZNVW3L' ;
2425const googleAdsId = ' AW-18316357590' ;
25- const googleAnalyticsId = ' G-VJ80VBL1L4' ;
2626
2727const siteUrl = siteConfig .url ;
2828const subpath = pageName === ' home' ? ' ' : pageName ;
@@ -86,13 +86,48 @@ const ogLocale = lang === 'es' ? 'es_CO' : 'en_US';
8686 <meta name =" twitter:image" content ={ ogImageUrl } />
8787
8888 <!-- Política de Seguridad de Contenido (CSP) para mitigar XSS y Clickjacking -->
89- <meta http-equiv =" Content-Security-Policy" content ="
90- default-src 'self';
91- script-src 'self' 'unsafe-inline' https://www.googletagmanager.com https://www.google-analytics.com blob:;
92- connect-src 'self' https://www.google-analytics.com https://stats.g.doubleclick.net https://www.google.com https://www.google.co.id https://formspree.io;
93- img-src 'self' data: https://www.google-analytics.com https://www.google.com https://www.google.co.id https://www.google.com.co https://googleads.g.doubleclick.net https://www.googleadservices.com;
94- font-src 'self' data:;
95- " />
89+ <meta
90+ http-equiv =" Content-Security-Policy"
91+ content ="
92+ default-src 'self';
93+
94+ script-src
95+ 'self'
96+ 'unsafe-inline'
97+ blob:
98+ https://www.googletagmanager.com;
99+
100+ connect-src
101+ 'self'
102+ https://www.google-analytics.com
103+ https://region1.google-analytics.com
104+ https://region2.google-analytics.com
105+ https://analytics.google.com
106+ https://stats.g.doubleclick.net
107+ https://googleads.g.doubleclick.net
108+ https://www.googleadservices.com
109+ https://formspree.io;
110+
111+ img-src
112+ 'self'
113+ data:
114+ https://www.google-analytics.com
115+ https://stats.g.doubleclick.net
116+ https://googleads.g.doubleclick.net
117+ https://www.googleadservices.com;
118+
119+ style-src
120+ 'self'
121+ 'unsafe-inline';
122+
123+ font-src
124+ 'self'
125+ data:;
126+
127+ frame-src
128+ 'self';
129+ "
130+ />
96131
97132 <!-- Google Consent Mode v2 — SIEMPRE primero, antes de cargar gtag.js.
98133 Por defecto TODO denegado: no se activan cookies de analítica ni de
@@ -129,17 +164,23 @@ const ogLocale = lang === 'es' ? 'es_CO' : 'en_US';
129164 navegador esté ocioso o a la primera interacción. Los comandos
130165 (js/config) se encolan de inmediato y gtag.js los procesa al cargar,
131166 respetando el consentimiento por defecto (denegado). -->
132- { googleAdsId && googleAnalyticsId && (
133- <script is :inline define :vars = { { googleAdsId , googleAnalyticsId }} >
167+ { googleAnalyticsId && googleAdsId && (
168+ <script is :inline define :vars = { { googleAnalyticsId , googleAdsId }} >
134169 gtag("js", new Date());
170+
171+ // Google Analytics
135172 gtag("config", googleAnalyticsId);
173+
174+ // Google Ads
136175 gtag("config", googleAdsId);
137176
138- var gtagLoaded = false;
177+ let gtagLoaded = false;
178+
139179 function loadGtag() {
140180 if (gtagLoaded ) return ;
141181 gtagLoaded = true ;
142- var s = document .createElement (" script" );
182+
183+ const s = document .createElement (" script" );
143184 s .async = true ;
144185 s .src = ` https://www.googletagmanager.com/gtag/js?id=${googleAnalyticsId } ` ;
145186 document .head .appendChild (s );
@@ -150,8 +191,12 @@ const ogLocale = lang === 'es' ? 'es_CO' : 'en_US';
150191 } else {
151192 setTimeout (loadGtag , 3000 );
152193 }
153- ["scroll", "pointerdown", "keydown", "touchstart"].forEach(function (ev) {
154- window .addEventListener (ev , loadGtag , { once: true , passive: true });
194+
195+ ["scroll", "pointerdown", "keydown", "touchstart"].forEach((ev) => {
196+ window .addEventListener (ev , loadGtag , {
197+ once: true ,
198+ passive: true ,
199+ });
155200 } );
156201 </script >
157202 )}
0 commit comments