SE-friendly link, with actual destination different

I need to have certain links on my site appear to go one place for search engines:

<a href=“http://example.com” …

but go through an intermediate script to track clicks:

… onclick=“window.location=‘http://example.org/track.php?id=112’;”>

I suppose that’s easy enough, but, if the user doesn’t have Javascript enabled, I’d like the click to still go through the tracking script.

Any suggestions?

I suppose that’s easy enough, but, if the user doesn’t have Javascript enabled, I’d like the click to still go through the tracking script.

According to this, it doesn’t seem like Javascript is what you should go for in the first place. By posting that here, you’re kinda saying “I want to use Javascript for this, but i need it to work without Javascript.”

Is there a way you could just

<?php require('track.php'); ?>

from your header in all your webpages and just pass a superglobal to it with your href? Or is that not at all how your tracking script works?

I guess I would need to know how your tracking script works to get an idea of how to approach this.

The ID in “http://example.org/track.php?id=112” is used to look up the href. The script then does a header() redirect to go to that location (in the meantime updating the counter for that href).

Am I being silly here? Since header() – according to PHP.net – does a 302 redirect, do I need to worry that SEs are first seeing an internal link? (Since they were seeing an internal link, I thought I needed to use an external link and use Javascript to change it to the tracker.)