Analytics
2.3K members online now
Understand information in your reports and troubleshoot reporting issues such as self-referrals, (not set) data, and inaccurate information
 
Guide Me
star_border
Reply

what message appears for do not track users

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Is it true GA does not respect Do Not Track browser headers? If so, what message do these visitors see on my site to let them know DNT does not apply?

1 Expert replyverified_user

what message appears for do not track users

[ Edited ]
Top Contributor
# 2
Top Contributor

GA, much like the rest of the tracking industry, does not respect DNT.

 

The most effective way of enforcing DNT is to get your browser's DNT settings and trigger tags (or not) based on the results.

 

<script>
var dnt = navigator.doNotTrack;
</script>
...
<!-- insert GA tracking code -->
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-123456798-1', 'auto');
  
  // fire a pageview only if DNT is not set
  if (dnt!=1) ga('send', 'pageview'); // <-- pay attention here

</script>
VP & Chief Evangelist at Hub'Scan | Contact me
Level 80 Digital Analytics Warrior, KPI Therapist and Keeper of the One True Tagging Plan