Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I want to build a small directory for programming-related websites only and I'm a little bit confused at the moment. I want to be able to track how many times visitors clicked links to certain websites, but I still want Google to pick-up that link as being towards site X, without losing any SEO value (meaning, for Google, that link still has to look like a clean backlink, not a link to a PHP file that redirects the user to another website).

Question is, if I use jQuery to post some data (simply "link x clicked") to a PHP script beforethe default behaviour (directing the user to the page), will Google penalize the link or will it still be as valuable as a normal back-link?

Thanks all, Claudiu

share|improve this question
add comment

3 Answers 3

A JavaScript-free way of doing this might be to use a 301 redirect. Google still passes PR when it's a 301 redirect (I'm not sure whether 302 passes PR), so if you use a 301 redirect from your tracking page, then you'll be fine. And 301 should also preserve referrer information.

Edit:

I want to elaborate on the logic of this method. As Tim noted below, this isn't actually the official use of a 301 redirect, which technically is a way for a web server to indicate that a resource has been permanently moved. Likewise, 302 is technically for indicating when a resource has been temporarily moved to a new location.

However, the 301/302 response codes have a history of being appropriated for other uses by browsers, by search engines and by developers. For example, before 303 existed, it was common to use a 302 redirect to respond to POST requests when you wanted to redirect the user to another page (ie. to prevent a page refresh resubmitting the form). This was technically not what a 302 is supposed to be used for, but due to the lack of alternatives, it was still standard practice to use 302 in this way. Today we have 303, so 302 redirects should no longer be used for this type of redirection, though many applications still do.

Another common nonstandard use of 301/302 redirects is for URL shortening. It's widely recommended for SEO purposes that, if you need to shorten a URL, you use a service that performs a 301 redirect. But technically the content hasn't been moved from the shortened URL to the destination; the shortened URL is just a new alias for it.

Still, when you choose between using JavaScript or 301 redirects for click-tracking, take the following into consideration:

  • Google recommends using the JavaScript method, and they're a bit of an authority on web analytics and SEO.
  • As Tim mentions, the JavaScript method prevents crawlers from being counted by your click tracker (though you could probably filter crawlers out another way).
  • Using the 301 redirection method doesn't conform with the official use of 301 laid out in the HTTP specs.
  • On the flip side, you do allow tracking without JavaScript.
share|improve this answer
    
This is totally not what 301s are for. Use one of the other Javascript solutions posted - these also stop crawlers counting as outbound clicks. –  Tim Fountain Oct 26 '10 at 14:46
    
@Tim Fountain: Can you cite a source for a 301 not counting as an outbound link. AFAIK, 301s are invisible to crawlers, so they will simply treat it as an outbound link to the redirect destination. If this does cause some unintended consequences, then I'd consider it an inappropriate use of 301, but otherwise it's like using XHR to fetch plain-text or JSON data. It's not what it was originally designed for, but there's nothing wrong with using it as such. –  Lèse majesté Oct 26 '10 at 15:07
    
I meant that the Javascript solutions are better because crawlers indexing your site won't be artificially raising your outbound click counts. There ways to reduce the affects of this, of course; but since this is not what 301s were designed for I don't see any reason to use this option over JS click tracking. –  Tim Fountain Oct 26 '10 at 15:34
    
Ah, I misunderstood what you meant. That's a valid point. But I wanted to offer a solution not dependent on JS. –  Lèse majesté Oct 26 '10 at 15:49
add comment

Google does give you a way to do it. For Asynchronous tracking use the code found here, http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55527.

share|improve this answer
add comment

Google analytics allows you to track outbound links.. another option would be to rewrite you links upon page load with jquery if you want to use a redirect script.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.