homepage Welcome to WebmasterWorld Guest from 54.166.84.82
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Google / Google SEO News and Discussion
Forum Library, Charter, Moderators: Robert Charlton & aakk9999 & brotherhood of lan & goodroi

Google SEO News and Discussion Forum

    
Is this o.k. for Google
Won't hijack pages or cause a problem?
rover

10+ Year Member



 
Msg#: 28651 posted 7:51 pm on Mar 19, 2005 (gmt 0)

I need to track the number of clickthroughs on outgoing links, but I don't want to stop the passing of PR to the external sites. So, I'm using the following solution:

-------------------

<script>
function clk(id,link){
window.location.href= 'http://www.mydomain.com/track.cgi?ID='+id;
return false;
}
</script>

Example of the link to an external site:

<a href="http://www.example.com" onclick="return clk(123,this)">

-------------------

I think that google spidering will bypass the javascript stuff, and just follow the link to the www.example.com external site.

Actual users who click on the link (and have javascript enabled) will allow the tracking to take place through the track.cgi script.

I checked, and if somehow google (or other spiders) follow the link in the tracking script with an ID number (e.g. [mydomain.com...] then it will go to the external site, and the server header response show 200 OK.

There is no 302 involved, so this wouldn't lead to any inadvertent hijacking problems would it?

Or does anyone else see any potential problems that this method could cause with google (or other major search engines)?

 

internet ventures

5+ Year Member



 
Msg#: 28651 posted 3:27 pm on Mar 20, 2005 (gmt 0)

I cant see it causing any problems. It is after all the exact same way Google counts clicks.

Wizard

5+ Year Member



 
Msg#: 28651 posted 8:02 pm on Mar 20, 2005 (gmt 0)

It's a good solution - Google currently doesn't follow onClick links. But it's likely it will eventually, so it's good to check logs.

It's essential to put the code outside the link - if you wrote 'onClick="location.href='www.mysite.com/redir.php?url=www.othersite.com'"', Google would be able to follow this, not because of parsing JavaScript, but because it fetches the links from any text, if I'm not wrong.

The other problem is, that if Mozilla/Firefox user clicks with middle button (opening the page in new tab), there is no onClick event generated, so you won't track this click.

You can avoid this problem writing a javascript that changes a link, like

'onMouseOver="change_link(this)"

function change_link (anchor) {

old_link = this.href;
new_link = 'www.mysite.com/redir.php?url=' + old_link;

this.href = new_link;

return true;
}'

But this is a complicated method, and there is a risk Google may think you're cloaking (it may think the same in onClick method though). It _is_ showing different link for Googlebot than for user anyway. But currently this methods are not penalized, and if used in good purpose, like in your case, they shouldn't ever be penalised.

rover

10+ Year Member



 
Msg#: 28651 posted 11:20 pm on Mar 20, 2005 (gmt 0)

Thanks for the feedback. Actually, I didn't realize but the method I was using was showing the link, and then using the other tracking link/redirect to send the user to the site.

So, I've changed to using the actual google method where it loads an image that triggers the tracking script, but the user is always taken to the link that is shown in the <a href> tag.

The Javascript:

<script>
function clk(n) { if(document.images){ (new Image()).src="/track.cgi?ID="+n; } return true;}
</script>

Example Link:

<a href="http://www.example.com" onmousedown="return clk(123)">Example Site</a>

I hope that wouldn't cause any problem with google or the other major search engines.

If anyone thinks that it would, I would be interested to hear about it...

rbacal



 
Msg#: 28651 posted 12:38 am on Mar 21, 2005 (gmt 0)

What would happen if you use the url in between the relevant <noscript> tags? Would google read that? Or would it still be within the javascript as google would read the thing?

internet ventures

5+ Year Member



 
Msg#: 28651 posted 3:12 pm on Mar 21, 2005 (gmt 0)

A link like the one below will get spidered by a search engine and should cause no problems. It's just a standard link with an onclick argument. Google will just ignore the onclick part which is fine.

<a href="http://www.example.com" onclick="return clk(123,this)"> example </a>

rover

10+ Year Member



 
Msg#: 28651 posted 6:42 pm on Mar 21, 2005 (gmt 0)

Thanks. That's what I figured. It's interesting, though, that actually it won't work for me if I use 'onclick' method, but it does work for 'onmousedown'. In other words:

The onclick version:

<a href="http://www.example.com" onclick="return clk(123,this)">

Doesn't complete the track.cgi script for me (clickthrough not recorded) on my server.

The onmousedown version:

<a href="http://www.example.com" onmousedown="return clk(123,this)">

Does work (the track.cgi script records the clickthrough).

I wonder if there is a timing issue that once the click is recorded, and the user is immediately redirected, that there is no time to load the image, and run the script?

Anyway, I noticed that Google also uses onmousedown rather than onclick.

internet ventures

5+ Year Member



 
Msg#: 28651 posted 7:53 pm on Mar 21, 2005 (gmt 0)

Yes, I have just noticed that I too use the onmousedown event to track clicks. I have been using this method for over a year without problems.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Google / Google SEO News and Discussion
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved