Get the referral url in javascript

2019-06-24 05:06发布

问题:

I want to see how much traffic I get from various URL shortening services like

bit.ly

tinyurl.com

But because they use 301 redirection, they don't show up in my analytics.

How can I find out who is redirecting the traffic?

Or

More precisely how could i get the referral url in javascript for different kind of redirection ?

回答1:

document.referrer

Example:

if (document.referrer && document.referrer != "")
      document.write('Thanks for visiting this site from ' + document.referrer);