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"; }}



Blocking tracking scripts

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



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