@@ -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,55 @@ 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.googletagmanager.com
103+ https://www.google-analytics.com
104+ https://region1.google-analytics.com
105+ https://region2.google-analytics.com
106+ https://analytics.google.com
107+ https://stats.g.doubleclick.net
108+ https://googleads.g.doubleclick.net
109+ https://www.googleadservices.com
110+ https://www.google.com
111+ https://pagead2.googlesyndication.com
112+ https://formspree.io;
113+
114+ img-src
115+ 'self'
116+ data:
117+ https://www.googletagmanager.com
118+ https://www.google-analytics.com
119+ https://stats.g.doubleclick.net
120+ https://googleads.g.doubleclick.net
121+ https://www.googleadservices.com
122+ https://www.google.com
123+ https://pagead2.googlesyndication.com;
124+
125+ style-src
126+ 'self'
127+ 'unsafe-inline';
128+
129+ font-src
130+ 'self'
131+ data:;
132+
133+ frame-src
134+ 'self'
135+ https://www.google.com;
136+ "
137+ />
96138
97139 <!-- Google Consent Mode v2 — SIEMPRE primero, antes de cargar gtag.js.
98140 Por defecto TODO denegado: no se activan cookies de analítica ni de
@@ -129,17 +171,23 @@ const ogLocale = lang === 'es' ? 'es_CO' : 'en_US';
129171 navegador esté ocioso o a la primera interacción. Los comandos
130172 (js/config) se encolan de inmediato y gtag.js los procesa al cargar,
131173 respetando el consentimiento por defecto (denegado). -->
132- { googleAdsId && googleAnalyticsId && (
133- <script is :inline define :vars = { { googleAdsId , googleAnalyticsId }} >
174+ { googleAnalyticsId && googleAdsId && (
175+ <script is :inline define :vars = { { googleAnalyticsId , googleAdsId }} >
134176 gtag("js", new Date());
177+
178+ // Google Analytics
135179 gtag("config", googleAnalyticsId);
180+
181+ // Google Ads
136182 gtag("config", googleAdsId);
137183
138- var gtagLoaded = false;
184+ let gtagLoaded = false;
185+
139186 function loadGtag() {
140187 if (gtagLoaded ) return ;
141188 gtagLoaded = true ;
142- var s = document .createElement (" script" );
189+
190+ const s = document .createElement (" script" );
143191 s .async = true ;
144192 s .src = ` https://www.googletagmanager.com/gtag/js?id=${googleAnalyticsId } ` ;
145193 document .head .appendChild (s );
@@ -150,8 +198,12 @@ const ogLocale = lang === 'es' ? 'es_CO' : 'en_US';
150198 } else {
151199 setTimeout (loadGtag , 3000 );
152200 }
153- ["scroll", "pointerdown", "keydown", "touchstart"].forEach(function (ev) {
154- window .addEventListener (ev , loadGtag , { once: true , passive: true });
201+
202+ ["scroll", "pointerdown", "keydown", "touchstart"].forEach((ev) => {
203+ window .addEventListener (ev , loadGtag , {
204+ once: true ,
205+ passive: true ,
206+ });
155207 } );
156208 </script >
157209 )}
0 commit comments