What is a referrer?

A referrer is the address of the page a visitor was on when they followed a link or sent a request to the current one.

Browsers send it in a request header named Referer, a misspelling that became part of the standard. JavaScript can read the page a visitor came from as document.referrer. It is empty when the visitor typed the address, used a bookmark, or came from a page or app that asked for it not to be sent.

How much is sent depends on the referrer policy. The browser default, strict-origin-when-cross-origin, sends the full address within one site but only the origin, such as https://example.com/, to other sites. So you usually learn which site sent a visitor, not which page.

For forms there are two useful referrers: the outside site that brought the visitor, and the page of your own site the form was sent from. Both help you see where inquiries come from. FormTango's drop-in script records the referring page with each submission.

javascript
// Copy the referring page into a hidden field before the form is sent
form.elements.referrer.value = document.referrer;

Related