From ac177a9d6346576934b346362465d1d6ba134275 Mon Sep 17 00:00:00 2001 From: Ben Hong Date: Thu, 22 Feb 2024 10:47:02 -0800 Subject: [PATCH] feat(docs-infra): add cookie consent gtag event default state This PR sets a default state for cookie consent of 'denied'. The other part of the PR exists in the angular/dev-infra repo which will grant permission when the user accepts the cookie banner. --- aio/src/app/shared/analytics.service.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/aio/src/app/shared/analytics.service.ts b/aio/src/app/shared/analytics.service.ts index 45cbee425bd07..a20694f4322ff 100644 --- a/aio/src/app/shared/analytics.service.ts +++ b/aio/src/app/shared/analytics.service.ts @@ -90,6 +90,17 @@ export class AnalyticsService { // Analytics 4 web UI under `Data Streams`. window.dataLayer = this.window.dataLayer || []; window.gtag = function() { window.dataLayer?.push(arguments); }; + + // Cookie banner consent initial state + window.gtag('content', 'default', { + ad_user_data: 'denied', + ad_personalization: 'denied', + ad_storage: 'denied', + analytics_storage: 'denied', + personalization_storage: 'denied', + wait_for_update: 500 + }); + window.gtag('js', new Date()); // Configure properties before loading the script. This is necessary to avoid