Google Analytics cookies still firing after adding the Usercentrics consent solution

Modified on Sat, 10 Jan at 4:19 PM

Depending on how your website is built and what scripts your website uses, sometimes manual code needs to be added to third party scripts in order to control them properly. 


After implementing and testing the Usercentrics consent solution on your website, if you notice that Google Analytics related cookies (such as "_GA") are still being loaded on users' browsers, you can add additional code to the Google Analytics script to ensure Usercentrics can properly control it. 


You need to add the following into the Google Analytics script:

type="text/plain" data-usercentrics="Google Analytics"


So if your Google Analytics 4 script looks like this: 

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-XXXXXXXXX');
</script>


You would update it to this: 

<!-- Google tag (gtag.js) -->
<script type="text/plain" data-usercentrics="Google Analytics" async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXX"></script>
<script type="text/plain" data-usercentrics="Google Analytics" >
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-XXXXXXXX');
</script>

Then clear cache and test the website.  You should see GA related cookies no longer load until after a user gives consent.


Still firing? 

Visit the Cookie Policy and Consent Tool questionnaire (scroll to bottom) and make sure you have the Service "Google Analytics" listed (not "Google Analytics 4").  If you have "Google Analytics 4" listed, be sure to remove that Service and click 'add new service' to add in Google Analytics. Or alternatively you can keep Google Analytics 4, but ensure that the manual control script lists "Google Analytics 4" instead (so it would say data-usercentrics="Google Analytics 4").


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article