Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with document.referrer

I'm having some trouble using document.referrer on some sites, even the reference site using HTTP protocol.

  1. In what circumstances document.referrer may be empty (except HTTPS to HTTP)?

  2. What is the best way to get the url reference only document.referrer?

  3. In my site, document.referrer is empty, but when I look in Analytics website of references appears.

like image 986
user1706458 Avatar asked Feb 21 '15 13:02

user1706458


1 Answers

document.referrer is not empty if your site URL was clicked from other website, like from google search, from facebook, twitter, etc...

So, If someone opens your site from bookmark o directly types your site URL, document.referrer is empty.

Let's see these examples:

Click this link http://www.w3schools.com/jsref/prop_doc_referrer.asp you can see that document.referrer is http://stackoverflow.com/questions/28646433/problems-with-document-referrer

If you search in google HTML DOM referrer Property, document.referrer will be http://google.es/...

And if you copy http://www.w3schools.com/jsref/prop_doc_referrer.asp opens new tab in your browser and paste it, document.referrer will be empty.

like image 71
Valijon Avatar answered Oct 03 '22 17:10

Valijon