HTTP headers | DNT

The HTTP DNT Header is a request header that allows users to choose if their activity could be tracked by each server and web application that they communicate with via HTTP. The generated header field is a mechanism that allows the user to opt-in or out of the tracking. Tracking allows user to experience personalized content on web. The option to opt-out of tracking was created with growing privacy demands among users.

The tracking preference can only be set if a user has enabled it. A user agent is not allowed to display a tracking preference expression if not enabled tracking preference is set by the user.



Directives :

The following field value is generated for HTTP DNT header field if the tracking preference is set as enabled

  • 1: This directive indicates that user prohibits tracking at the target site.
  • 0: This directive indicates that user allows tracking on or the user has granted an exception at the given target site.

Note : A DNT Header Field can have zero or more extensions. The extensions are determined by the user agent. A DNT header field can be inserted without a field value if the extension is defined but the tracking preference is not set.


  • This is a example from W3C(World Wide Web Consortium) of a DNT header set to field value – 1:
    GET /something/here HTTP/1.1
    DNT: 1
  • The value of DNT header field can be checked using JavaScript’s navigator.doNotTrack property.
    // prints "1" if DNT is enabled; "0" 
    // if the user opted-in for tracking;
    // prints "null" if unspecified
    1. Safari 7.1.3+ , Edge , IE11 and subsequent versions use window.doNotTrack rather than navigator.doNotTrack
    2. Prior to Firefox 32, navigator.doNotTrack would report values of yes and no rather than 1 and 0.

Supported Browsers: The browsers supported by HTTP DNT Header are listed below

  • Google Chrome
  • Internet Explorer
  • Microsoft Edge
  • Firefox
  • Opera
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.