Forum Moderators: DixonJones

Message Too Old, No Replies

Here's how to track direct (clean) links

Why didn't I think of this before?

         

MichaelBluejay

9:32 am on Mar 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Maybe I'm missing something, but here's a way to track direct links:

<A href="http://example.com"
onclick="location.href='myClickTracker.cgi'; return false;">
Click me click me click me!
</A>

When someone clicks the link then Javascript sends them over to the click tracking script, which then sends them to the destination site.

But the link remains clean, which is what advertisers want for SEO purposes.

If the user has Javascript disabled, it's okay, because the link still works.

This fails to count clicks for users with Javascript disabled, but to me that's more than made up for by the fact that I now don't have to filter out a buttload of bot clicks.

Maybe this is old news, but I seem to recall reading threads where people said that you can either track clicks, or have a clean link, but not both. So at least for anyone else besides me who didn't know it was possible to do otherwise, here ya go.

[edited by: Woz at 11:31 pm (utc) on Mar. 27, 2005]
[edit reason] examplified URL [/edit]

dirkji

7:55 am on Mar 27, 2005 (gmt 0)

10+ Year Member



Hi Michael,

Can you point me to a script that can be used to work with these kind of links?

Dirk.

MichaelBluejay

12:14 pm on Mar 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Um, no, but maybe I could write one real quick:


#!/usr/bin/perl -w

open (FILE, '<adcounter.txt');
@data = <FILE>;
close (FILE);

$theCount = int($data[0]) +1;

open (FILE, '>adcounter.txt');
print FILE $theCount;
close (FILE);

print "Location:http://YourAdvertiser.com\n\n";

This writes the count data to a text file called "adcounter.txt". Every time someone clicks the link as described in my first post, this script will add 1 to the number in the adcounter.txt file, then sends the visitor over to whatever URL you specify.