@justai/cuts 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Base.astro +6 -1
package/package.json
CHANGED
package/src/Base.astro
CHANGED
|
@@ -185,7 +185,12 @@ const localePath = (l: string) => (l === defaultLocale ? "/" : `/${l}/`);
|
|
|
185
185
|
{gaId && (
|
|
186
186
|
<script is:inline define:vars={{ gaId }}>
|
|
187
187
|
window.dataLayer = window.dataLayer || [];
|
|
188
|
-
function gtag
|
|
188
|
+
// gtag is put on WINDOW, not declared as `function gtag`, and this is load-bearing: `define:vars`
|
|
189
|
+
// wraps this inline script in an IIFE to scope the injected `gaId`, so a `function gtag` here
|
|
190
|
+
// would be trapped in that IIFE — and the consent banner's own inline script (in the body) calls
|
|
191
|
+
// gtag, giving "gtag is not defined" the moment a European visitor clicks Allow/Decline (the
|
|
192
|
+
// choice is never applied, the banner never closes). Global on window, both scripts see it.
|
|
193
|
+
window.gtag = window.gtag || function () { window.dataLayer.push(arguments); };
|
|
189
194
|
gtag("js", new Date());
|
|
190
195
|
gtag("consent", "default", { ad_storage: "denied", ad_user_data: "denied", ad_personalization: "denied", analytics_storage: "granted" });
|
|
191
196
|
// EEA + UK + CH: deny analytics until the visitor consents (the banner below grants it).
|