Quote:
|
Originally Posted by ramprage What are some of the best methods to track paid links to your website instead of just looking at your visitor logs? Is there some kind of link tracking program where you can setup a link for each partner so you can track the click throughs?
eg: mysite.com?ref=siteA
I know I could write a simple script to do this but I was hoping someone was using something they could recommend? |
There are different methods of doing it. The easiest one is to do via database. I'll be showing you how to do it using MySQL and PHP.
Code:
//Create table in mysql, assuming that you already have a database setup
create table referrals(
id int(2) not null auto_increment,
name varchar(100) not null,
hits int(10) not null,
);
// Then for each of your referrals, you add then into the database.
insert into referrals values(NULL,'Site A','0');
To process the request and you do:
PHP Code:
<? // page.php
mysql_connect("$db_host","$db_user","$db_pass") or die("Sorry, we couldnt connect to the database.");
mysql_select_db("$db_db") or die("Sorry, we couldnt select the database.");
$q = mysql_query("SELECT * FROM referrals WHERE name='$ref'");
if(mysql_num_rows($q)) {
mysql_query("UPDATE referrals SET hits=hits+1 WHERE name='$ref'");
} else { print "ERROR: Wrong Referral Site!"; }
?>