0

I want to create a GDPR complying website using Google Analytics. For that, I would like to ask the user for consent before actually saving any cookies.

Unfortunately, I cannot find any documentation on that topic, as AngularFire has next to no documentation (and even less for the new API) and Firebase provides only documentation for IOS/Android.

What I have tried:

  1. Providing a config using the providers array in app.module.ts
  2. Try setting setAnalyticsCollectionEnabled(analytics, false); in provideAnalytics
  3. Try setting window['ga-disable-analyticsId'] = true; in main.ts

All these methods still save cookies to my browser on load.

Are there any official or unofficial methods to get AngularFire to do what I want?

Name AngularFire Firebase Angular
Version 7.2.0 9.6.1 13.1.0
MauriceNino
  • 6,214
  • 1
  • 23
  • 60
  • May sound silly but did you replace analyticsId by your actual analytics id ? The property on the Windows object must be set before GA initializes, not familiar with angularFire but I believe it should then ne sera on window before AngularFire starts up. – lkostka Jan 15 '22 at 23:38
  • @lkostka Do you mean that in the `window['ga-disable-analyticsId']` I have to actually write `window['ga-disable-G-ABCD......']`? `main.ts` should 100% run before anything else, so it should run before AngularFire though, so that is not the problem. – MauriceNino Jan 17 '22 at 08:45
  • yes as per those docs here, you should write the id https://developers.google.com/analytics/devguides/collection/gtagjs/user-opt-out – lkostka Jan 17 '22 at 12:57
  • 1
    @lkostka Can you form that as an answer? I can't check right now if this is what fixes it, but it might help other people with the same problem. – MauriceNino Jan 17 '22 at 20:41

1 Answers1

1

It mat not be the solution here, but according to the documentation (https://developers.google.com/analytics/devguides/collection/gtagjs/user-opt-out) data collection is disabled at the stream id (GA4) or property id (UA) level, so inside window['ga-disable-analyticsId], analyticsId should instead be the actual id.

lkostka
  • 711
  • 1
  • 5
  • 10
  • 1
    This was totally the solution, but I already solved it without AngularFire. After implementing AngularFire again, the `setAnalyticsCollectionEnabled(analytics, false);` solution worked as well. – MauriceNino Jan 24 '22 at 19:38