How does Google Analytics know about referral sites?

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?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 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?

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply