Search Engine Friendly Exit Counter
Support this website by purchasing prints of my photographs! Check them out here.We built this script about a month ago that counted the exit clicks with affiliates. The url for the script (which, if your reading this, your probably familiar with) is /exit.php?go=###
where ###
is the unique id for each affiliate.
The problem with this script is that it is not search engine friendly. The exit.php, as you can probably guess, spits out a meta refresh tag that redirects the user to the affiliate site. Google doesn't like the meta refresh tag. Therefore, by using that system, we don't help out our affiliates. Google will simply see the link to a page called exit.php and ignore everything.
Google follows plain boring anchor links (<a href="www.com">www</a>
) and uses the title attribute to help index the link. Google does not follow javascript links. Well, if Google doesn't follow them, why is this tutorial mentioning them? All you need to do to make a search engine friendly link is place the javascript link inside of the normal anchor tag.
Here is the code:
<a href="http://www.google.com/">
<img src="affiliates/google.gif" alt="Google" title="Google"
onclick='window.location="exit.php?go=25"'>
</a>
The anchor tag encompasses the image tag. The anchor tag links to the normal website. The image tag has the onclick attribute which links to the affiliate script.
Why this works: Google is parsing the vanilla anchor tag, and the user's browser, when the affiliate image is clicked, decides to follow the onclick instead of the anchor. Google is happy and see's their normal link to another site, the user is happy as they see the normal exit url link when hovering over the link, and the webmaster is happy because they can track the exit counts.