My site now respects the Do Not Track (DNT) header [UPDATED]

Update: The tracking is no longer completely removed when DNT is enabled but all IP addresses are anonymized. I remind you about the Google Analytics Opt-Out plugin if you want to avoid tracking all together.

Google Analytics will from now on not track if you use the DNT header. Thou shall not be tracked 🙂

Note that I cannot guarantee that you won’t be tracked in every way using my site due to third-party plugins like social media buttons etc.

Technical treat

If you’re interested in the implementation it’s as you probably expected very basic:

function dont_track_if_dnt() {
  if ( isset( $_SERVER['HTTP_DNT'] ) && $_SERVER['HTTP_DNT'] ) {
    // DNT is on, do something to prevent tracking here
  }
}
add_action( 'init', 'dont_track_if_dnt', 99999 );
This entry was posted in Do Not Track (DNT) and tagged , , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.