Skip to main content

noreferrer and Referrer Policy

Every time a visitor clicks a link, or a page loads an image or a script, the browser may tell the destination where the request came from. That information is called the referrer, and you can control it. The tool most people meet first is rel="noreferrer", and behind it sits a small, useful system called Referrer Policy.

The link-focused basics are in Link Security. This lesson goes deeper into the referrer itself: what is sent, why it matters, and the controls you have.

What You Will Learn​

  • What the referrer is, and why the header is spelled Referer
  • What a browser sends by default
  • What rel="noreferrer" does, and what it also implies
  • The eight referrer policy values
  • Four ways to set a policy, and which wins
  • Why secrets must never live in URLs
  • The trade-offs for analytics and embeds

The Big Idea​

A referrer is a postcard that travels with the request, saying "I came from this page". Sometimes that is helpful. Sometimes it reveals more than you intend, such as a private path or a token in the address. Referrer Policy lets you decide how much goes on the postcard.

index.html
<!-- One link: send no referrer -->
<a href="https://sensitive.example.org/" rel="noreferrer">Visit the site</a>

<!-- One link: choose a specific policy -->
<a href="https://partner.example.com/" referrerpolicy="origin">Partner</a>

<!-- Images, scripts, iframes and more accept it too -->
<img src="https://cdn.example.net/logo.png" alt="Logo" referrerpolicy="no-referrer">

<!-- Whole page, in the head -->
<meta name="referrer" content="strict-origin-when-cross-origin">
Or as a response header (all pages)
Referrer-Policy: strict-origin-when-cross-origin

What Is the Referrer?​

When a browser requests something from another site, it can add a header named Referer that holds the address of the page making the request. The spelling is a historical typo in the original web standard, and it stuck, so the header is Referer while the policy and the attribute use the correct spelling, "referrer". JavaScript can read the same value from document.referrer.

The destination can use it for good reasons, such as analytics, "back to where you came from" features, and basic checks on where requests come from. It can also learn things you would rather keep private.

What gets sent​

The browser may send:

  • the full address, with path and query (https://shop.example.com/account/orders?id=4821),
  • or the origin only (https://shop.example.com/),
  • or nothing.

It never sends the part after #, and it never sends usernames or passwords from the address.

The Default​

Modern browsers apply a default that is equivalent to strict-origin-when-cross-origin:

Request goes toWhat is sent
The same originThe full address
A different origin, still httpsThe origin only
A less secure destination (https to http)Nothing

That is a sensible baseline. But browsers differ in age and settings, and you may want something stricter. Being explicit makes your intent clear, and protects visitors whose browsers use older defaults.

rel="noreferrer"​

Adding rel="noreferrer" to a link tells the browser not to send the Referer header for that click.

<a href="https://sensitive.example.org/" target="_blank" rel="noreferrer">Visit the site</a>

It also has a second effect: it implies noopener, so a page opened in a new tab gets no window.opener link back to yours. That second effect is the subject of noopener. The two are separate ideas that happen to arrive together.

rel="noreferrer" works on a, area, and form elements. For images, scripts, stylesheets, and iframes, use the referrerpolicy attribute instead.

info

Modern browsers already treat target="_blank" links as if they had noopener. They do not remove the referrer for you, because that is a separate decision. You choose it with noreferrer or a policy.

The Eight Policy Values​

ValueSame originOther origin (https)Downgrade to http
no-referrerNothingNothingNothing
no-referrer-when-downgradeFull addressFull addressNothing
originOriginOriginOrigin
origin-when-cross-originFull addressOriginOrigin
same-originFull addressNothingNothing
strict-originOriginOriginNothing
strict-origin-when-cross-originFull addressOriginNothing
unsafe-urlFull addressFull addressFull address

Open the Referrer Lab, type a page address with a query string, and change the destination. Watch each row change. Then try the scenarios in the Policy Picker.

A quick way to choose:

  • No outside party should learn anything: no-referrer.
  • A good all-round default: strict-origin-when-cross-origin.
  • An internal system: same-origin.
  • Avoid unsafe-url. Its name is a warning, because it sends the full address everywhere, even to insecure sites.

Four Ways to Set a Policy​

WhereScopeExample
Referrer-Policy HTTP headerThe whole page, set by the serverReferrer-Policy: same-origin
meta tag in the headThe whole page<meta name="referrer" content="same-origin"> (written in the page's head)
referrerpolicy attributeOne element or request<img referrerpolicy="no-referrer">
rel="noreferrer"One link, area or form<a rel="noreferrer">

A setting closer to the request wins. An element's own referrerpolicy or rel="noreferrer" overrides the page-wide policy. Choose a page-wide policy first, then add exceptions only where needed.

Why This Matters: Secrets in URLs​

The biggest referrer risk is not the policy. It is what your own URLs contain. If a page address holds a password-reset token, a session ID, an email address, or a private document path, any request that page makes can leak it through the referrer: to an analytics script, a font host, a CDN image, or a link the visitor clicks.

Rules to follow:

  1. Never put secrets in a URL. Send tokens in a request body or a header, or keep them in a cookie marked HttpOnly and Secure.
  2. If a one-time code must be in the address, use a strict policy on that page, and exchange the code for a session and redirect away quickly.
  3. Avoid putting personal data in query strings. Names, emails, and IDs end up in history, server logs, and referrers.
  4. Set a page-wide policy so one forgotten img cannot leak the address.

The Referrer Lab warns you when it spots words such as token or reset in the address.

Trade-Offs to Know​

  • Analytics. If you link out with noreferrer, the destination site sees the visit as "direct", not as coming from you. That is the point, but you lose credit for sending traffic. Likewise, when visitors arrive at your site from places that use strict policies, your analytics may show less detail. For links you control, campaign parameters such as utm_source in the address are an alternative, and they are visible to the destination by design.
  • Embeds and APIs. Some embedded players, map keys, and image hosts check the referrer, so no-referrer can make them fail. If an embed breaks, read the provider's documentation before loosening your policy, and use origin rather than the full address if a check needs a site name.
  • Request-origin checks. Some servers use Referer to check that a request came from their own site. Rely on proper protections instead, such as tokens and SameSite cookies, covered in Secure Forms. Separately, the Origin header is sent on many cross-origin requests, and Referrer Policy does not control it.
  • Not anonymity. noreferrer hides where the visitor came from. It does not hide their IP address, browser details, or anything else the destination can see.

Checking Your Setup​

  1. Open DevTools, then Network, and click a request to another site. Under Request Headers, look for Referer.
  2. Check the Response Headers of your page for Referrer-Policy.
  3. In the Console, type document.referrer on a page you reached by a click. It shows what the browser was told.
  4. In Elements, search for referrerpolicy and noreferrer to see where they are used.
  5. Search your site for addresses that contain token=, reset=, email=, or session=.

Best Practices​

  1. Set a page-wide policy, and use strict-origin-when-cross-origin as a baseline.
  2. Use no-referrer or same-origin on pages with sensitive addresses.
  3. Never put secrets in URLs.
  4. Use rel="noreferrer" for links to sensitive or unrelated sites.
  5. Avoid unsafe-url.
  6. Test embeds after tightening a policy.
  7. Document exceptions, and keep them rare.
  8. Do not rely on Referer to protect your server.

Quick Checklist​

  • A page-wide policy is set by header or meta
  • No page address contains a secret or personal data
  • Sensitive pages use no-referrer or same-origin
  • rel="noreferrer" is used where nothing should be shared
  • Embeds and analytics still work after the policy
  • No use of unsafe-url
  • The server does not depend on Referer for protection

Security and Privacy Notes​

  • Referrers can reveal behaviour. A destination may learn which pages of your site its visitors came from, and combine that with other data. Sending less is a privacy-friendly default.
  • Visitors may have their own settings. Some browsers and extensions trim or remove referrers. Do not build a feature that breaks when the referrer is empty.
  • Privacy law can apply to this data. Whether a referrer counts as personal data depends on where you operate. This is not legal advice, so check the rules that apply to you.
  • Policies apply to the request, not the content. They do not stop a page from displaying private information to someone who is allowed to see it.

Global Audience Notes​

  • Privacy expectations vary by region, and strict defaults are welcome nearly everywhere.
  • Some partners and payment providers need a referrer to verify the requesting site. Follow their current guidance, and prefer sending the origin only.
  • Mixed http and https sites are still common in some regions. The downgrade rules above matter more there.
  • Language does not change anything here, but addresses can include non-English words, so use clear, neutral address paths that do not reveal personal details.

Common Mistakes to Avoid​

  1. Putting tokens or emails in the address, then worrying about the policy.
  2. Using noreferrer for security and expecting it to hide a visitor's IP address.
  3. Confusing noreferrer with noopener. The first controls the header, and the second controls the window.opener link.
  4. Forgetting referrerpolicy on images and scripts.
  5. Setting no-referrer everywhere and breaking an embed or an analytics tool.
  6. Using unsafe-url.
  7. Misspelling the header or attribute. The header is Referer. The policy is Referrer-Policy. The attribute is referrerpolicy.
  8. Expecting Referer to be present, and writing code that fails without it.
  9. Relying on Referer as a security check on your own server.
  10. Never testing after changing the policy.

Practice Time​

  1. In the Referrer Lab, keep the default values. Which policies send the token to the other site?
  2. Click "Same site". Which policies still send the full address?
  3. Click "A plain http site". Which policies send nothing?
  4. Remove token=abc123 from the address. What changes in the warning?
  5. Complete all four scenarios in the Policy Picker.
  6. Open DevTools on any page, click a link to another site, and find the Referer header in the Network panel.
  7. Add <meta name="referrer" content="same-origin"> to a test page, and repeat step 6.
  8. Bonus: add rel="noreferrer" to one link, click it, and compare the request headers.

Quick Recap​

Click a question to check your answer.

1. What is the referrer?

The address of the page that made a request, sent in the Referer header (and readable as document.referrer), so the destination can see where the visitor came from.

2. What does rel="noreferrer" do?

It stops the browser from sending the Referer header for that link, and it also implies noopener.

3. What is a good default policy?

strict-origin-when-cross-origin: full address to the same origin, origin only to other https sites, and nothing to insecure sites.

4. Which setting wins when several are used?

The one closest to the request. An element's referrerpolicy or rel="noreferrer" overrides the page-wide header or meta tag.

5. Why must secrets stay out of URLs?

Addresses leak through referrers, history, and server logs. A token in the address can reach any site the page contacts.

6. Does noreferrer make a visitor anonymous?

No. It only removes the referrer. The destination still sees the IP address and other browser details.

Key Takeaways​

  • The referrer tells a destination where a request came from.
  • rel="noreferrer" sends no referrer and also implies noopener.
  • There are eight policies. Use strict-origin-when-cross-origin as a baseline, and avoid unsafe-url.
  • Closest setting wins: element, then page.
  • Keep secrets out of URLs. This matters more than any policy.
  • Test embeds and analytics after you change a policy.

Next up: noopener, where you will learn how a new tab can reach back into the page that opened it, and how to close that door.