Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the correct referer via JavaScript if the referrer uses https?

I use document.referrer to read the referrer url via JavaScript e.g. if a user clicked a google search result link and lands on my website:

http://www.google.com -> Click on search result -> redirect -> http://www.mysite.com => document.redirect returns correct referrer

Now, this works fine as long as the google search result was delivered via http but if instead httpS is used, document.referrer is always empty:

https://www.google.com -> Click on search result -> redirect -> http:/www.mysite.com => document.redirect is empty

How can I work around this?

like image 936
Timo Ernst Avatar asked Jan 29 '26 20:01

Timo Ernst


1 Answers

When you search from https://www.google.com, websites you visit from our organic search listings will still know that you came from Google, but won't receive information about each individual query.

Please read: http://googleblog.blogspot.com/2011/10/making-search-more-secure.html

like image 73
compliance Avatar answered Feb 01 '26 14:02

compliance



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!