Revision 1136331 of DNT

  • Revision slug: Web/HTTP/Headers/DNT
  • Revision title: DNT
  • Revision id: 1136331
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment new page

Revision Content

{{HTTPSidebar}}

The DNT (Do Not Track) request header indicates the user's tracking preference. It lets users indicate whether would prefer privacy rather than personalized content.

Header type {{Glossary("Request header")}}
{{Glossary("Forbidden header name")}} yes

Syntax

DNT: 0
DNT: 1

Directives

0
The user prefers to allow tracking on the target site.
1
The user prefers not to be tracked on the target site.

Examples

Reading Do Not Track status from JavaScript

The user's DNT preference can also be read from JavaScript using the {{domxref("Navigator.doNotTrack")}} property:

navigator.doNotTrack; // "0" or "1"

Specifications

Specification Status Comment
{{SpecName('Tracking','#dnt-header-field', 'DNT Header Field for HTTP Requests')}} {{Spec2("Tracking")}} Initial definition.

Browser compatibility

{{Compat}}

See also

  • {{domxref("Navigator.doNotTrack")}}
  • {{HTTPHeader("Tk")}}

Revision Source

<div>{{HTTPSidebar}}</div>

<p>The <strong><code>DNT</code></strong> (<strong>D</strong>o <strong>N</strong>ot <strong>T</strong>rack) request header indicates the user's tracking preference. It lets users indicate whether would prefer privacy rather than personalized content.</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">Header type</th>
   <td>{{Glossary("Request header")}}</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Forbidden header name")}}</th>
   <td>yes</td>
  </tr>
 </tbody>
</table>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">
DNT: 0
DNT: 1
</pre>

<h2 id="Directives">Directives</h2>

<dl>
 <dt>0</dt>
 <dd>The user prefers to allow tracking on the target site.</dd>
 <dt>1</dt>
 <dd>The user prefers not to be tracked on the target site.</dd>
</dl>

<h2 id="Examples">Examples</h2>

<h3>Reading Do Not Track status from JavaScript</h3>

<p>The user's DNT preference can also be read from JavaScript using the {{domxref("Navigator.doNotTrack")}} property:</p>

<pre class="brush: js">
navigator.doNotTrack; // "0" or "1"</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('Tracking','#dnt-header-field', 'DNT Header Field for HTTP Requests')}}</td>
   <td>{{Spec2("Tracking")}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>

<p>{{Compat}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{domxref("Navigator.doNotTrack")}}</li>
 <li>{{HTTPHeader("Tk")}}</li>
</ul>
Revert to this revision