document.referrer
Script-readable copy of the Referer, available the moment a page loads.
In one line
Can tell which page you came from the moment the page loads
Script-readable copy of the Referer, available the moment a page loads.
Same previous-site data as the header, readable by any script on the page including third-party tags. Tag managers use it to label traffic sources; Safari 26 and Brave can blank it for classified tracker scripts.
What it can and can't do
What the user does: Nothing. It happens when a page loads after you clicked a link
It can
- Tell which site or page sent you
- Use that to credit a campaign, ad or search
- Share the origin of the previous page with analytics tools
It cannot
- See the full address of the previous page for cross site links, by default only the site name
- See pages you visited earlier than the last one
- Know the search words from most search engines
- Know anything if you typed the address or used a bookmark
Browser support
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 1 | 2008-12-11 | Value depends on Referrer-Policy |
| Edge | Supported | 12 | 2015-07-29 | Value depends on Referrer-Policy |
| Firefox | Supported | 1 | 2004-11-09 | Value depends on Referrer-Policy |
| Safari | Supported | 1 | 2003-06-23 | Value depends on Referrer-Policy |
| Safari on iPhone | Supported | 1 | 2007-06-29 | Value depends on Referrer-Policy |
| Chrome on Android | Supported | 18 | 2012-06-27 | Value depends on Referrer-Policy |
| Samsung Internet | Supported | 1.0 | 2013-04-27 | Value depends on Referrer-Policy |
How a site asks for it
| API | document.referrer |
| Browser compat keys | api.Document.referrer |
| How access is granted | none |
| What the user sees | None |
| Needs a secure context (HTTPS) | No |
| Needs a user gesture | No |
| How long it lasts | Per document |
| How to take it back | Clear site data, browser privacy settings |
| Inside an iframe | Not listed |
Data you get
What comes back: URL string or empty string
Shape: string
How often: once at load
| Field | Type | Unit | Range | Precision |
|---|---|---|---|---|
referrer | string | URL | empty or URL | origin only cross-origin by default |
Technical limits
- Follows the sender's Referrer-Policy
- Empty on direct visits, bookmarks, typed URLs and rel=noreferrer links
- Not available to cross-origin frames beyond what their own request carried
The story
What it is
Any script on a page can read which site you came from.
For you
You never see it. When a page loads, scripts on it, including third party ones, can check where you came from. That may be a search engine, a friend's post or an ad.
For makers
Tag managers use it to label traffic as search, social or ads. Analytics and ad scripts use it for attribution. Because any script can read it, it is also a leak path for details of the page you were on before.
Where you see it
| Type | Example | Apps |
|---|---|---|
| analytics | A blog sees that most readers came from a Reddit post and tags them as social traffic. | Google Analytics, Reddit |
| ads | An ad script checks if you came from a partner site and then shows that partner's offer. | None named |
| shopping | A shop sees you came from a price comparison site and shows a better coupon. | Google Shopping, PriceGrabber |
| security | A login page checks the referrer to spot hits from known phishing sites. | None named |
| games | A game site checks if you came from a streamer's page and unlocks a bonus for that creator's fans. | Twitch, Kongregate |
| media | A paywall that checks if you came from a search engine, and lets you read a free article. | Wall Street Journal |
Risks
- Leaks where you were before
- Third party scripts can read it too
What the platform says
- Mozilla: document.referrer. Developer docs describe it as the address of the page that linked to the current one.
Good uses and abuse
Legitimate uses
- Traffic source attribution
- Landing page personalisation
Known abuse
- Cross-site history sniffing by tag vendors
Scores
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 3 of 5 | How revealing the data is |
| Utility | 4 of 5 | How useful it is to honest apps |
| Friction | 0 of 5 | How much the user has to do |
| Fingerprint bits | 1 | Rough identifying entropy, when known |
History
- 2025-09, Safari 26: Advanced Fingerprinting Protection on by default in regular browsing: classified scripts lose access to document.referrer and URL query parameters (per reporting, verify scope)
Related capabilities
Related
- Referer header and Referrer-Policy default. Can tell a site which page you came from, trimmed to the site name cross site
Sources
How well checked: Based on official documentation.