2

My site is abc.example. xyz.example links to my site. Google Analytics reports that users come via xyz.example to my site.

How does Google Analytics know that users have come from the link on xyz.example?

1 Answer 1

1

Almost all browsers send the referrer as meta information in the headers when they request a page. An HTTP request usually looks something like:

GET /mypage.html HTTP/1.1
Host: mysite.example
Referer: https://othersite.example/otherpage.html

This referrer information is usually logged by the web server. See the Apache documentation for the combined log format. A log entry might look like:

127.0.0.1 - - [10/Oct/2000:13:55:36 -0700] "GET /mypage.html HTTP/1.1" 200 2326 "https://othersite.example/otherpage.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"

Log analysis software such as Awstats and Webalizer have always taken these server log files and mined useful stats from them. They have used the logged referrer information to build a list of sites and pages that send the most traffic.

This referrer is also available to JavaScript in the page as document.referrer. The Google Analytics tracker runs as JavaScript in the page. It looks at the referrer via the JavaScript variable and transmits it (along with lots of other information) to the Google Analytics server. Google Analytics then uses that information to build the referrer report that you can see.

This referrer information is usually pretty good but there are cases in which the information is not sent:

  • Most bots
  • Browser extensions that disable referrer
  • Some meta refresh redirects and iframes
  • HTTPS to HTTP links
  • Links marked with noreferrer

It has also become common for spammers to inject referrer data into your Google Analytics report by pinging the tracker without ever visiting your site. See How to fight off Google Analytics referrer spammers?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.