Log in

View Full Version : Affilate tracker?



vleonica
06-28-2007, 12:11 AM
I am looking for a way to track the number of people sent from my site to another site via a link. Another words, how many people who were at my site clicked on the link that then took them to a different site.

thetestingsite
06-28-2007, 12:21 AM
Well, you could make a PHP script that stores the info in a MySQL database. Just make your links something like this:



<a href="http://example.com/affiliate.php?url=http://blah.org/">blah.org</a>


and use this as a basis for the php script:

affiliate.php


<?php
$url = $_POST['url'];

$conn = mysql_connect('localhost', 'username', 'password');
mysql_select_db('database', $conn);

$info = mysql_query("SELECT * FROM `table` WHERE `url`='$url'");
$q = mysql_fetch_array($info);

$count = $q['count'];

$count = $count+1;

mysql_query("UPDATE `table` SET `count`='$count' WHERE `url`='$url'");

header('Location: '.$url);
?>


Hope this helps.