Following the General Data Protection Regulation (GDPR) the user has to give his consent before any cookie is set.
I use google / firebase analytics in a Flutter web site. When the user opens a page immediately two cookies are stored: _ga and _ga_SOMECODE.
How can I make google analytics postpone these cookies so that I can first ask the user's consent and leave to him the choice to allow a cookie for the use of google analytics - or to reject both?
I am looking for something like this:
in index.html
// Initialize Google Analytics <script> var analyticsConfig = { enabled: false }; firebase.analytics(analyticsConfig); </script>
Somewhere on the first page:
Accept statistics cookies? [yes] [no]
and in the corresponding dart code:
// Enable / disable Google Analytics FirebaseAnalytics analytics = getAnalytics(); analytics.setAnalyticsCollectionEnabled(usersAnswer);
In the ideal case the analytics code would only be loaded when the user provided a positive answer. In the case the user's choice would be [no] the analytics code in the code base would do nothing.
How can I implement something similar?
Thanks, Dietrich