PDA

View Full Version : Search engine bots "seeing through" Javascript?



Shockt
12-01-2006, 08:55 PM
In my efforts to build my website's backlinks, I have come across many sites that like to track the number of clicks their links get on their links page or directory. Example:
http://www.photolinks.com/PhotoShop_Tutorials.html
You will notice my site, Photoshop Guides, has not recieved a direct link. Instead, my link goes to:
http://www.photolinks.com/redirect.html?p_id=2006112203062062
From what I understand, I will only benefit from the traffic of this link. I do not gain any PR benefit.

In an effort to improve these link click counting/tracking scripts, I was going to make a Javascript-based script. At first, I thought AJAX would be the best solution. When the user clicks the link, an AJAX request is sent to record the click and in the meantime, the user is taken to their destination via direct link. But certain ways of clicking that link aren't tracked.

The onclick event triggers when clicked, but using my scroll wheel to click it and open the link in a new Firefox tab, the AJAX function isn't called.

So I moved to onmouseup but realized that if you are tabbing through links and hit Enter, the "click" isn't recorded either.

Then I decided to try onfocus to just change the link to the tracking script's URL. So when the page loads, you have a direct link. But when the link is in focus (clicked, tabbed through, etc), the URL changes to your tracking script. This then lead to me researching about Googlebot's ability to "read through" and possibly execute Javascript.

Now finally, my question. If I have a link that looks like this:

<a href="http://www.photoshopguides.com" onfocus="this.href='track.php?url=http://www.photoshopguides.com'">Photoshop Guides</a>...will I gain the PR benefit of the direct link via href? Or will Googlebot, and other search engine bots, be able to "see through" my Javascript mask and give the PR gain to the tracking script or give no PR gain at all?

KLB
12-02-2006, 05:39 AM
I do find that some bots (particularly bad bots) try to sleuth out URLs from JavaScript and visit those URLs. For best SEO practices one should not rely on SE bots seeing or following any JavaScript URLs. At the same time it might be a good idea to structure tracking URLs like the one above such that they can be added to a deny list in your robots.txt file. For example you might do:

<a href="http://www.photoshopguides.com" onfocus="this.href='track.php?page=/index'">Photoshop Guides</a>
<a href="/contact.html" onfocus="this.href='track.php?page=/contact'">Contact us</a>

Then add the following to your robots.txt file:


User-agent: *
Disallow: /track.php

On the back side in (in PHP or whatever) you could append the ".html" if you so desired. Renaming "URL=" "page=" and removing the domain name and ".html" will stop some bots from trying to sleuth out the URL of the JavaScript. The robots.txt file will stop legitimate bots (e.g. Google bot) from trying to index your tracking script page.

Chris
12-02-2006, 07:05 AM
Using event handlers in a link do not hinder SEs. So feel free.