Get the referral url in javascript
Asked Answered
P

1

7

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 ?

Politick answered 9/11, 2010 at 7:50 Comment(1)
HAve a look here: blog.bit.ly/search/referrersApoplexy
S
10

document.referrer

Example:

if (document.referrer && document.referrer != "")
      document.write('Thanks for visiting this site from ' + document.referrer);
Serge answered 9/11, 2010 at 7:54 Comment(2)
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.Politick
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.Serge

© 2022 - 2024 — McMap. All rights reserved.