Honoring Do Not Track with Google Tag Manager

You can use the native Do Not Track setting in browsers in combination with Google Tag Manager to better honor visitors’ requests not to be tracked.

This method prevents trackers in Google Tag Manager from being loaded for visitors who have turned on Do Not Track. This can ensure that your website is not serving tracking bugs, beacons, or pixels at all to users who have chosen not to be tracked, regardless of whether those 3rd parties are honoring the Do Not Track request.

For one website that I run, I’ve decided on a trial basis to use this method to not load pixels from Google AdWords, Facebook, Twitter, MailChimp, and LinkedIn for users who have Do Not Track enabled, but I am still serving Google Analytics code to everyone, leaving the honoring of Do Not Track to Google Analytics in that case.

This is definitely not for everyone, and depending on your setup and what tags you choose to apply this to, it can completely break things like conversion tracking and remarketing (but that’s kind of the idea behind Do Not Track). This is a nice way to be more honest & fair as a marketing technologist toward people who have specifically requested not to be tracked, and you’ll give those people faster page load times to boot.

First, tell Google Tag Manager to read the browser’s Do Not Track JavaScript variable (thanks, David Walsh).

In Google Tag Manager, enter the Container where you’ll be limiting tracking.

Click “Variables,” then “New,” then “Variable Configuration.”

For “Choose variable type,” select “JavaScript Variable.”

For “Global Variable Name,” enter:

navigator.doNotTrack

Name this new GTM variable something other than “Untitled Variable,” like “Do Not Track.”

Next, you’ll create a Trigger that reads your new Do Not Track GTM variable.

Click “Triggers,” then “New,” then “Trigger Configuration.”

For “Choose trigger type,” select “Page View.”

Switch “This trigger fires on” to “Some Page Views.”

Under “Fire this trigger when an Event occurs and all of these conditions are true,”

  • Set the first dropdown to “Do Not Track” (or whatever you named your GTM variable)
  • Set the next dropdown to “equals”
  • Enter the number 1 in the third input field

Click away from the Trigger Configuration card, and see “This trigger fires on” followed by “Do Not Track equals 1” (again, you may have named your GTM variable differently).

Name this new GTM trigger something other than “Untitled Trigger,” like “Do Not Track Enabled.”

Finally, you’ll apply this Trigger to existing Tags that you want to not load when a user has Do Not Track turned on.

Choose “Tags,” then click on Tag.

Click on the “Triggering” card to enter editing mode.

If you have no triggering exceptions set up for this Tag, click “ADD EXCEPTION.” If you already have triggering exceptions, click the “+” next to “Exceptions.”

For “Choose a trigger,” select “Do Not Track Enabled” (or whatever you called your GTM trigger).

Click “SAVE.”

Enter Preview and Debug mode if you wish and test this configuration, and when you’re ready to go live with this change, Publish your Container.

That’s it, you’re done! You’ve made your website a better experience for users who are requesting more privacy.