Cookie consent to block Google to track users

Hello everyone!

I know this (or similar) topic has been going through already in this community (Disable analytics packages until users accept GDPR cookie consent) but it has been quite a while since the topic was raised and I thought to ask again to see if anyone has meantime found a solution and would like to share it.

I have React Cookie Consent installed and since i live in the EU country where the “reject” button is required, I would need to block the Frontity Google Analytics package (or prevent Google to track users) when the visitor is clicking on the reject button. How would it be possible to implement such a thing?

The following

    analytics: {
      pageviews: {
        googleAnalytics: false
      events: {
        googleAnalytics: false

Setting both pageviews and events false does not prevent for Google to track users. Any other ideas that can work maybe?

The moment you have set the Tracking ID (or Container ID when using GTM) it will add the scripts to the head (and body).

So no matter what you do, it will always trigger the initial tracking.

I’d guess the only solution would be a change in the analytics packages to check for an “am I allowed to track” state before injecting the script tag(s).
Big question will be; what’s the default? And; how to make stupid-proof without too much programming knowledge.