On this page
Outbound links can tell the destination which page sent a visitor. A referrer policy lets you limit that information: you can share the full referring page URL, share only your site's origin, or send no referrer at all.
This guide explains how to set referrer policy for external links, compare the privacy and analytics trade-offs, and check what your browser sends.
Verification note: The W3C Referrer Policy specification and browser documentation were not available to consult for this article. The examples have not been executed here; verify behavior in the browsers and environments you support.
Key Takeaways
- Set a
Referrer-Policyresponse header for a document-wide policy, or usereferrerpolicyon an individual link when that link needs a different policy. strict-origin-when-cross-originshares the referring URL with same-origin destinations, but normally shares only the origin with HTTPS cross-origin destinations and nothing on an HTTPS-to-HTTP downgrade.no-referreris useful when the destination should not receive aRefererheader. It does not make a visitor anonymous.- Test actual outbound requests: browser settings, extensions, redirects, and other factors can affect what a destination receives.
Header or link attribute?
The Referrer-Policy HTTP response header sets a policy for the document served in that response. For example, configure your web server, hosting platform, or application to send:
Referrer-Policy: strict-origin-when-cross-origin
This is a useful site-wide baseline when applied to your pages. The header must be sent with the source page's response; a header on the destination's response cannot change the request that has already arrived there.
The referrerpolicy attribute sets a policy for a particular link:
<a href="https://partner.example/" referrerpolicy="no-referrer">
Visit the partner site
</a>
Use the attribute for exceptions to your baseline. An individual link can specify a policy that shares less—or potentially more—than the document-wide policy, so review overrides carefully. You can also use rel="noreferrer" on a link when the intent is to suppress referrer information:
<a href="https://partner.example/" rel="noreferrer">
Visit without a referrer
</a>
Do not rely on either markup or a header being applied until you have checked the response and request in your target browsers. Support and behavior can vary by browser and version.
Advertisement
Compare referrer policy values
Suppose the source page is https://site.example/articles/guide?campaign=demo#top. The table shows representative Referer values a destination may receive. A browser or privacy tool can suppress information further. The fragment, #top, is not included in these referrer values.
| Policy | Same-origin HTTPS destination | Cross-origin HTTPS destination | HTTPS-to-HTTP destination |
|---|---|---|---|
no-referrer | No Referer | No Referer | No Referer |
same-origin | Full source URL without fragment | No Referer | No Referer |
origin | https://site.example/ | https://site.example/ | https://site.example/ |
strict-origin | https://site.example/ | https://site.example/ | No Referer |
origin-when-cross-origin | Full source URL without fragment | https://site.example/ | https://site.example/ |
strict-origin-when-cross-origin | Full source URL without fragment | https://site.example/ | No Referer |
no-referrer-when-downgrade | Full source URL without fragment | Full source URL without fragment | No Referer |
unsafe-url | Full source URL without fragment | Full source URL without fragment | Full source URL without fragment |
In this example, the full source URL means https://site.example/articles/guide?campaign=demo. An origin consists of scheme, host, and port; a different scheme or port makes a destination cross-origin even if its hostname is the same.
Which policy should you choose?
- Use
strict-origin-when-cross-originas a practical baseline when partners may benefit from knowing the referring site but do not need the page path or query. Same-origin requests can still receive those details. - Use
no-referrerfor links where you do not want the destination to receive referrer information. Expect some referral analytics or attribution to be unavailable. - Consider
same-originif your own pages need referrer information but external sites do not. - Avoid
unsafe-urlfor sensitive page URLs. It can disclose paths and query strings to external sites, including over an HTTPS-to-HTTP downgrade. Similarly,originandorigin-when-cross-origincan disclose the origin on a downgrade.
Some browsers may apply a restrictive default when no policy is set, but defaults and compatibility are browser-dependent. Set an explicit policy and verify it rather than relying on an assumed default.
Test outbound links in a browser
This local test compares same-origin and cross-origin navigation without contacting a third party. It requires Python, a browser with developer tools, and two free local ports. Use only test data in the URLs.
- Create an empty directory. In it, save the following as
start.html:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Referrer policy test</title>
</head>
<body>
<p><a href="/landing.html" referrerpolicy="strict-origin-when-cross-origin">Same origin</a></p>
<p><a href="http://localhost:8001/landing.html" referrerpolicy="strict-origin-when-cross-origin">Cross origin</a></p>
<p><a href="http://localhost:8001/landing.html" referrerpolicy="no-referrer">Cross origin, no referrer</a></p>
</body>
</html>
- In the same directory, save a simple destination as
landing.html:
<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><title>Landing page</title></head>
<body><p>Test destination</p></body>
</html>
- From that directory, start these servers in two separate terminals:
python3 -m http.server 8000
python3 -m http.server 8001
- Open
http://localhost:8000/start.html?campaign=demo#top. Open developer tools, select the Network panel, and enable Preserve log if available. - Click Same origin and inspect the navigation request for
landing.html. In its request headers, look forReferer. Return to the start page and repeat for each of the other links.
With strict-origin-when-cross-origin, expect the same-origin request to include the source path and query, while the request to port 8001 should contain only http://localhost:8000/. With no-referrer, expect the header to be absent. The different ports make the second destination cross-origin. Stop each server with Ctrl+C when finished.
Advertisement
Test limitations
This lab uses HTTP on localhost, so it does not demonstrate an HTTPS-to-HTTP downgrade. To check downgrade behavior, use controlled HTTPS and HTTP endpoints in an appropriate test environment. The lab also tests link attributes, not a response-header configuration: to test your deployed baseline, inspect your source page's response headers for Referrer-Policy, then inspect outbound navigation requests from links without an override.
Developer tools show the browser's view of a request. If you need to know what a server actually received, inspect logs on a destination you control, taking care not to retain sensitive data. Redirects can create additional requests with different referrer behavior; inspect each hop. Browser privacy settings, extensions, and intermediaries can also change results.
Common Mistakes
- Treating a policy as anonymity. A destination can still receive a visitor's IP address and other information, and may use cookies or other signals. A policy does not hide all browsing activity.
- Putting secrets in URLs. Paths and query strings can appear in referrers, logs, browser history, and other places. Do not put credentials or sensitive personal data there.
- Confusing the source and destination policies. Set the header on the page containing the outbound link. The destination cannot retroactively change the incoming request.
- Assuming a policy guarantees analytics. Browsers or privacy tools may omit referrers, and redirects or navigation flows can affect attribution.
- Testing only one browser or one link. Check relevant browsers, link-level overrides, and redirect paths in your own deployment.
Best Practices
- Choose and explicitly configure a document-wide policy that matches your privacy needs.
- Audit individual
referrerpolicyattributes andrel="noreferrer"links for intentional exceptions. - Keep sensitive information out of URLs even when your policy suppresses external referrers.
- Document the analytics trade-off: origin-only sharing may identify the referring site without identifying the referring page; no-referrer may remove that signal altogether.
- Recheck behavior after changes to hosting configuration, redirects, or supported browsers.
Conclusion
Start with an explicit document-wide policy, then use link-level settings for justified exceptions. Test actual requests and treat referrer control as one privacy measure—not a guarantee of visitor anonymity.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.