6

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 ?

Atul
  • 4,463
  • 5
  • 23
  • 19

1 Answers1

9

document.referrer

Example:

if (document.referrer && document.referrer != "")
      document.write('Thanks for visiting this site from ' + document.referrer);
RPM1984
  • 72,246
  • 58
  • 225
  • 350
  • Using document.referrer we get the redirected referral but we cannot get the referral for 301 redirection. for example - 1.html having a 301 redirection to 2.html and if we try to set the document.referrer on 2.html we get undefined or blank value. – Atul Nov 09 '10 at 08:07
  • 2
    Not much you can do then. If *you* were doing the 301, you could tack on the referrer to the querystring. But since you're not, you can only grab what the request has given you. The code doing the 301 needs to tack on the referrer to the URL. – RPM1984 Nov 09 '10 at 08:12