Helpdesk

Home » Helpdesk » How To's, Additional Resources and Best Practices » How to add doNotTrack to Google Tag Manager (GTM)

How to add doNotTrack to Google Tag Manager (GTM)

Set up the Variable


In Google Tag Manager, open a Container where you’ll be implementing this feature. Go to Variables > New, then click Variable Configuration. 


  • Type: Custom JavaScript
  • Paste this code (if the variable returns “1”, then Do Not Track is enabled, otherwise it will be undefined<script>
function (){if (navigator.doNotTrack == "1" || window.doNotTrack == "1"){return "1"; }}

GTM Custom JS



Blocking tracking scripts

Create a blocking trigger and add it as an exception to all tracking tags within GTM container. Here’s a trigger:


GTM Exception

GTM GA Pageview


Read More: https://www.analyticsmania.com/post/respect-do-not-track-parameter-google-tag-manager



 

Did you find what you’re looking for?

Real People. Real Results.

We have decades of experience in all aspects of UX design, development, and marketing. Contact us to see how we can help you.