From c13a5b11caa604135b84f2f096f04b90a57c11e7 Mon Sep 17 00:00:00 2001 From: Ben Hong Date: Thu, 29 Feb 2024 09:59:24 -0800 Subject: [PATCH] fix(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. --- .../app/core/services/analytics/analytics.service.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/adev/src/app/core/services/analytics/analytics.service.ts b/adev/src/app/core/services/analytics/analytics.service.ts index 74d2483c23922..0de5f87814bab 100644 --- a/adev/src/app/core/services/analytics/analytics.service.ts +++ b/adev/src/app/core/services/analytics/analytics.service.ts @@ -64,6 +64,18 @@ export class AnalyticsService { window.gtag = function () { window.dataLayer?.push(arguments); }; + + // Cookie banner consent initial state + // This code is modified in the @angular/docs package in the cookie-popup component. + // Docs: https://developers.google.com/tag-platform/security/guides/consent + window.gtag('content', 'default', { + ad_user_data: 'denied', + ad_personalization: 'denied', + ad_storage: 'denied', + analytics_storage: 'denied', + wait_for_update: 500, + }); + window.gtag('js', new Date()); // Configure properties before loading the script. This is necessary to avoid