eXceem

Go Back   eXceem > Websites > Website Design Guides & Articles

Claim your amazing £1,000 slots booster bonus now!


Useful referral tracking for PHP websites

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 ...

Reply
 
Thread Tools
Old 11-02-12, 09:25 AM   #1
iPod Nano 1GB
 
Plume_Tray's Avatar
 
Join Date: Feb 2012
Location: Southend, Essex
Posts: 83
Plume_Tray is on a distinguished road
Send a message via twitter to Plume_Tray

Useful referral tracking for PHP websites


For 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">
This Pre-req was found in this thread.

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);
?>
Step 2: Create the following directory: htdocs/register/ref

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!
 
Reply With Quote
Old 11-02-12, 01:34 PM   #2
iPod 20gb
 
mrplow's Avatar
 
Join Date: Sep 2005
Location: London
Posts: 667
mrplow is an unknown quantity at this point
also make the /ref folder writeable or it won't work
 
Reply With Quote
Old 11-02-12, 01:41 PM   #3
iPod 20gb
 
mrplow's Avatar
 
Join Date: Sep 2005
Location: London
Posts: 667
mrplow is an unknown quantity at this point
sorry I forgot to thank you for the nice idea
 
Reply With Quote
Old 11-02-12, 03:56 PM   #4
iPod Nano 1GB
 
Plume_Tray's Avatar
 
Join Date: Feb 2012
Location: Southend, Essex
Posts: 83
Plume_Tray is on a distinguished road
Send a message via twitter to Plume_Tray
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.
 
Reply With Quote
Reply

Tags
php, referral, register, signup, tracking

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off





All times are GMT. The time now is 08:14 PM.
All trademarks and copyrights held by respective owners. Forum posts are owned by the poster.

Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO
no new posts