Tracking Clicks on Links
As Internet Marketers, we want to know what works and what doesn’t. As regards Ads, we want to know which one’s give us the best click-through-rate (CTR). Also, when we send out an email containing our links, it is nice to measure how many clicks each link received.
Some 3rd party services provide us with click tracking. For example, Aweber let’s you insert click-tracking links into your emails. Here is an example:
clicks.aweber.com/y/ct/?l=BLyeV&m=9E6ahG0FoNqvX&
b=2I0B5cgIoj7QyifOUtKVLw
It’s quite a long, ugly-looking link don’t you think?
Other services such as TinyUrl.com let you create cloaking URLs that hide the destination URL from the visitor. These don’t actually log the clicks.
I feel these kinds of links are off-putting to people since they are hiding the destination. There is no clue as to what product is being linked to either.
With my Kiosk.ws web hosting I can create urls like this: www.adscube.com/goto/product-name/1
In this case we have descriptive words I.e. “goto” and “product-name”. So the visitor will feel more comfortable having been given a better idea of the nature of the link. The number is to track which particular link or banner for this product was clicked.
Also, I am using my own domain name in the URL.
When somebody clicks this link, a php script on my site records the click and then diverts the visitor’s browser to the final destination URL. The destination URL is looked up in the database for one corresponding to the product-name.
I log the visitor’s IP address, time of click, referring page and browser type in a database. This let’s me check for repeat clicks by the same visitor, where they came from, what browser they used and how many clicks each link got.
So this is very useful information and I don’t need to share it with anyone else.
A simpler way to achieve this is to write the data to text files. I’ll show you how I used to do it.
First of all, we set up a directory to store the click log files. Call this click-log for example. Then set the directory permissions to 777. This allows your script to write files to this directory and allows you to open the files in your web browser.
Now here is the php script I wrote:
// Get the product ID
if (isset($_GET["p"])){
$pid = $_GET["p"];
// Get any tracking code
if (isset($_GET["t"])) {
$tc = $_GET["t"];
} else $tc = "none";
// Open/create the click log file
$fn = "click-log/".$tc."_".date("d-m-y").".txt";
$fp = fopen($fn, "a+"); // Create the file or open it
// Get visitor data
$ip = getenv("REMOTE_ADDR"); // Their IP address
$agent = getenv("HTTP_USER_AGENT"); // Browser or Bot identifier
$ref = getenv("HTTP_REFERER"); // Referring page
$t = date("H:i"); // Time stamp
fwrite($fp, "$pid\t$ip\t$t\t$ref\t$agent\n"); // Record the click data
fclose($fp);
// Now redirect the browser
$loc = "Location: http://clicksafe.$pid.hop.clickbank.net/?tid=$tc";
header($loc); /* Redirect browser */
}
exit;
?>
Save this to the root of your site and call it click.php
This particular script was written to redirect to click bank products. Instead of product names though, it only uses product ID numbers.
Here is an example URL:
www.yoursite.com/click.php?p=123&t=sidebar
Here, 123 is the product ID and “sidebar” is a tracking code.
A further step is to use what’s known as .htaccess to re-write a cleaner URL to this format.
So our URL can be:
www.yoursite.com/goto/123/1
In a file called .htaccess you would add this code:
RewriteEngine On RewriteRule ^goto/([0-9a-z]+)/$ click.php?pid=$1 RewriteRule ^goto/([0-9a-z]+)/([0-9a-z]+)$ click.php?pid=$1&t=$2
Your hosting may not support all the features I mentioned here but Kiosk.ws hosting certainly does. If you purchase your hosting through my link, I can help you set up this kind of click tracking.
Have fun testing your Ads!



