| |||||||
This is a discussion on Useful referral tracking for PHP websites within the Website Design Guides & Articles forums, part of the Websites category; For those using PHP & Apache you can use this code to track all user clicks from your website through ...
![]() |
| | Thread Tools |
| | #1 |
| iPod Nano 1GB | Useful referral tracking for PHP websitesFor those using PHP & Apache you can use this code to track all user clicks from your website through to your respective referral link. With Freebiejeebies it shows only signed up referrals but what if you wanted to see all potential referrals i.e those that didn't sign up too, to enable you to see total traffic going from website to referral link and work out sign ups vs total referral traffic. Pre-req: you need to be using "register/index.php" in place of all your href referral links. In this "register/index.php" file you need the following in the HEAD section: Code: <meta http-equiv="Refresh" content="0; url=http://insert-your-referral-link-here"> The code: Step 1: in the register/index.php, you need to put the following code inside the HEAD section and immediately before the above META tag: Code: <?php
$UserIP = $_SERVER['REMOTE_ADDR'];
$File = "ref/ref_".date('Ymd_His')."_".$UserIP.".out";
$Handle = fopen($File, 'w');
$Data = "";
fwrite($Handle, $Data);
fclose($Handle);
?>
Thats it. So, when a user clicks on the "register/index.php" link on your website, it will create a blank file in the "htdocs/register/ref" directory on your server before sending the user to your referral site: register/ref/ref_20120210_222620_94.168.113.109.out This will give you a unique file for each referral click showing date, time, and the users IP address. Hopefully, this might provide someone useful data. Word of caution, make sure you have some sort of housekeeping in place if your site generates alot of traffic as the ref directory could become quite cumbersome. Enjoy! |
|
| | #2 |
| iPod 20gb Join Date: Sep 2005 Location: London
Posts: 667
![]() | also make the /ref folder writeable or it won't work |
|
| | #3 |
| iPod 20gb Join Date: Sep 2005 Location: London
Posts: 667
![]() | sorry I forgot to thank you for the nice idea |
|
| | #4 |
| iPod Nano 1GB | Thanks mrplow - and good spot btw. Re writeable folders - for anyone without SSH access or chmod access or less savvy at linux/unix, your FTP software can do this for you. I'm using FTP Surfer at the moment which automatically makes the folder writeable upon creation, it will also allow manual tweeks.
__________________ Free Apple iPad 3 & More | GadgetFreebies.co.uk Join a Conga for 2 FREE green referrals Consoles.Freebiejeebies Conga HDTV.Freebiejeebies Conga |
|
![]() |
| Tags |
| php, referral, register, signup, tracking |
| Thread Tools | |
| |