Well, i figured i too needed to track my outgoing traffic, so here is a fast and simpel javascript/jquery solution that works for me:
Code:
function outboudTraffic( obj ){
// obj comes from a ahref
// get the src of the ahref object
var link = $( "#" + obj.id ).attr( "href");
// post the link value as an clicked_link post variable ( $_POST['clicked_link'] )
$.post("api.php", {
clicked_link : link
}, function(data){
//i use this to alert debugging information
//i turn it off when going live
alert( data);
});
}
On the api.php:
// make sure that the $_POST is coming from your domain and that you are not being
// spammed.
if ( isset( $_POST['clicked_link'] ) && !empty( $_POST['clicked_link'] ) ){
// insert it into a database
//
}