Get the referral url in javascript

Atul picture Atul · Nov 9, 2010 · Viewed 13.6k times · Source

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 ?

Answer

RPM1984 picture RPM1984 · Nov 9, 2010

document.referrer

Example:

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