My out.php script uses two databases and a .php file.
Create two databases:
urls (id,url)
LinkTracker (id,lid)
Db "urls" will list all your external links.
Db "LinkTracker" will be updated whenever someone clicks an external link. So if Google's entry in "urls" is:
id url
9 http://www.google.com
"LinkTracker" will be inserted with:
id lid
1000 9
Where lid is the link's id in "urls"
"LinkTracker" will grow and you'll be able to see how many times users leave your site and what link they click. You could even add the current data to LinkTracker to plot clicks over time.
Now to the out.php file. For example:
out.php?LinkId=9
will forward to http://www.google.com
PHP Code:
if(isset($_GET['LinkID'])){
// the querystring is set, then execute the script
$LinkID = (int) $_GET['LinkID'];
dbConnect(); // this is the function call to connect to your database
$query = "insert LinkTracker set lid = $LinkID";
@mysql_query($query);
$query = "select url from urls where id = $LinkID";
$result = sql_query($query);
$rd = $result[0][0];
header("Location: $rd");
}else{ // no querystring, send back to WebSitePublisher.net
header("Location: http://www.websitepublisher.net");
}
Bookmarks