Forum Moderators: phranque
Now, I'm no JavaScript or SEO guru, but as far as I know, here's how you could do it:
The search engine spider only looks at the HREF in your link and ignores any JavaScript-based onClick actions. Therefore you have an onClick action that triggers an AJAX-based script. For example, the interior of the tag might be...
A HREF="http://clickthroughurl.com"
onClick="registerClick('clickthroughurl.com');"
The registerClick function stops the user from leaving the page, uses an AJAX routine to slap clickthroughurl.com into your click counting database, get confirmation it was added, and then uses a JavaScript redirect to forward the user on to the intended URL. If your site is reasonably fast and the user has a reasonably fast connection, the lag will be barely noticeable.
The downside... any user who has JavaScript disabled will not have their click counted. Depending on whose stats you believe, this could mean an undercounting of clicks by anywhere from 3-10%.
Cheers,
Greg