navigator.doNotTrack reflects the user’s old Do Not Track preference ("1", "0", or null). Learn why DNT failed, the values, safer alternatives, five examples, and try-it labs.
01
Kind
Read-only property
02
Returns
String or null
03
Status
Deprecated
04
Standard?
Non-standard
05
Values
"1" / "0" / null
06
Use today?
Avoid
Fundamentals
Introduction
Do Not Track was meant to be a polite signal: the user asks sites not to track them, and sites voluntarily comply. In practice, many advertising systems ignored the signal.
navigator.doNotTrack exposes that preference in JavaScript (matching the DNT HTTP header). MDN now treats the whole approach as discontinued — ineffective for privacy and potentially harmful as fingerprinting noise.
💡
Learning vs shipping
This tutorial explains the property so you can recognize legacy code. Do not build new privacy logic on DNT alone.
Concept
Understanding the doNotTrack Property
Think of doNotTrack as a historical preference flag — not an enforceable lock against trackers.
"1" — user requests not to be tracked (DNT enabled).
"0" — user opted in to tracking (per MDN’s example notes).
null — no preference / unset in many browsers.
HTTP twin — same idea as the DNT request header.
Why it failed — cooperative only; ignored by many trackers; added fingerprint bits.
Foundation
📝 Syntax
General form of the property:
JavaScript
navigator.doNotTrack
Value
A string ("1" or "0") or null.
Common patterns (legacy / learning only)
JavaScript
// MDN-style log (do not rely on this for privacy):
console.log(navigator.doNotTrack);
// "1" if DNT enabled; "0" if opted-in; otherwise null
// Prefer modern signals when available:
if (navigator.globalPrivacyControl === true) {
// User has Global Privacy Control enabled (where supported)
}
Cheat Sheet
⚡ Quick Reference
Goal
Code / note
Read DNT
navigator.doNotTrack
Request no tracking
"1"
Opted in
"0"
Unset
null
New projects
Do not use (deprecated)
Modern check (where available)
navigator.globalPrivacyControl
Snapshot
🔍 At a Glance
Four facts to remember about navigator.doNotTrack.
Returns
"1" | "0" | null
Preference
Status
deprecated
Avoid shipping
Standard
non-standard
Discontinued DNT
Better path
GPC / cookies
Enforceable privacy
Compare
📋 DNT vs Modern Privacy Signals
navigator.doNotTrack
Modern approaches
Model
Ask sites politely
Browser / law / GPC enforcement
Status
Deprecated + Non-standard
Actively evolving
Reliability
Often ignored
Stronger when browser-enforced
Side effect
Extra fingerprint bit
Designed to reduce tracking
Use in new apps?
No
Yes — follow current guidance
Hands-On
Examples Gallery
Examples follow MDN navigator.doNotTrack patterns for learning. Prefer Try It Yourself to inspect your browser. Do not treat these checks as a complete privacy solution.
📚 Getting Started
Read the raw value and map it to plain language.
Example 1 — Read doNotTrack
MDN-style console log of the current preference.
JavaScript
console.log(navigator.doNotTrack);
// prints "1" if DNT is enabled; "0" if opted-in; otherwise null
Many modern setups return null because DNT UI was removed or defaults to unset.
Example 2 — Human-Readable Label
Translate the value into a short status string (for demos only).
JavaScript
function dntLabel(value) {
if (value === "1") return "DNT: request no tracking";
if (value === "0") return "DNT: opted in to tracking";
return "DNT: unset / null";
}
console.log(dntLabel(navigator.doNotTrack));
navigator.doNotTrack is Deprecated and Non-standard. Some browsers still expose it for compatibility; others return null or remove DNT UI. Do not depend on it for privacy.
✓ Deprecated · Non-standard
Navigator.doNotTrack
Learn the values for legacy code. Prefer Global Privacy Control and enforceable browser protections for new work.
LegacyAvoid in new apps
Google ChromeLegacy DNT — often unset / limited UI; check current behavior
Legacy
Microsoft EdgeChromium-based — follow current DNT exposure
Legacy
OperaLegacy exposure may vary
Legacy
Mozilla FirefoxHistorically exposed DNT; treat as legacy
Legacy
Apple SafariTracking prevention differs — do not rely on doNotTrack
Legacy
doNotTrackLegacy
Bottom line: Read doNotTrack only to understand or remove legacy branches — never as your sole privacy control.
Wrap Up
Conclusion
navigator.doNotTrack is a deprecated, non-standard snapshot of the old DNT preference. Learn the "1" / "0" / null values so you can read legacy code — then migrate to stronger privacy mechanisms.
Deprecated DNT signal — learn it, don’t ship on it.
5
Core concepts
🚫01
Values
"1" / "0" / null
API
⚠02
Status
Deprecated
Avoid
🚫03
Standard
Non-standard
Legacy
🔍04
Problem
Often ignored
Why failed
🔒05
Better
GPC / protections
Modern
❓ Frequently Asked Questions
It returns the user’s Do Not Track preference as a string "1" (request not to be tracked), "0" (user opted in to tracking), or null (no preference / unset). It mirrors the DNT HTTP header.
No. MDN marks it Deprecated and Non-standard. The DNT specification was discontinued because it relied on voluntary cooperation and was widely ignored, while also adding fingerprinting surface.
Browsers are moving toward enforceable privacy features such as Global Privacy Control (for example navigator.globalPrivacyControl where available), third-party cookie restrictions, and stronger tracking protections — not cooperative DNT headers.
MDN notes the signal can add fingerprint entropy in headers/APIs. Trackers that ignored the preference could still use the presence of DNT as another identifying bit.
No. It is a read-only Navigator property reflecting the browser preference. Users change it in browser settings (where the UI still exists).
Per MDN’s example: "1" if DNT is enabled, "0" if the user opted in for tracking, otherwise null.
Did you know?
MDN’s blunt takeaway: DNT was not only ineffective — it could help trackers by adding another distinguishing bit to the user’s fingerprint while still being ignored.