Affiliate or Pay Per Click Cookie Tracking! - PHP / MySQL Tutorials
 
  Buy Ebooks, Video Games, DVDs, Electronics and more !
Home | Help Forums | Web Design Tutorials | Free Swishmax Downloads Make Money Online Blog . Free Image and Photo Sharing and Hosting

 

 

Company

Home

Nework Details

Tutorials

SWiSH 2

SWiSHMax

Flash MX

PHP & MySQL

HTML / JScript

Adobe Photoshop

Corel Draw

Gimp

Miscellaneous

Downloads

Templates

Plugins

Fonts

Wallpapers

Free Images

Scripts and Codes

Products

E-Books

SWiSH BB

SWiSH Templates

SWiSH-DB Newsletter
Subscribe to our newsletter : GO
  Partners / Affiliates

   Free image hosting
   Web Design Pakistan
   Swish Templates
   SWiSH Climax
   Talkfreelance Community
   Template Desire
   Lite boards
   Script Sector
   GimpTalk
   13dots
   Idea Designs
   PHP Cafe
   Sposatoettore
   Free swishmax templates
   Swishzone

Manage your site with Flax Article Content Management System
Affiliate or Pay Per Click Cookie Tracking!
Category : PHP / MySQL | Level : Intermediate | Language : English
Ask Question | Read Comments | Post tutorial | Previous | Next

Web www.swish-db.com

Ok I am posting my 2 day project here in the hope that it can be of some help to someone. This little bit of code could easily be adapted to do a variety of diff things.
Enjoy everyone...

CODE

<?
//+******************************************************************+
//     .:]Affiliate or Pay Per Click Marketing Cookie Tracker[:.     |
//                    Copyright 2004 Shannon Prue                    |
//     Use of this script is restricted Non-Commercial / Learning    |
//     Only, If you would like to use this commercially mail me @    |
//     Inspiration AT gmail.com for permission.                      |
//     __________________________________________________________    |
//      This script in a nutshell will drop 3 cookies on a users     |
//      computer when they arrive at your website, One to count      |
//      number of visits the user has been to your website,          |
//      One to specify how they found your site, and One to show     |
//      what keywords were used to find your site.   This info       |
//      can later be extracted say during an order process to        |
//      track marketing campaignes or track affiliate sales.         |
//      I have added a debug mode to test the cookie proccess, as-   |
//      well as added comments for easy adaptation.                  |
//      an example a url that would drop all 3 cookies is as         |
//      follows:  example.php?src=ov&kw=my+search+term               |
//+******************************************************************+
$visitcount = $HTTP_COOKIE_VARS["visits"];
$url = $HTTP_REFERER;
$debug = 'true'; //debugger.... Leave blank to turn off debug mode

// check if referrer is from inside site (so that it only drops the cookie once)
if (preg_match("/yoursite.com/i", $url)) {
  $ignore = 'yes';
      } else {
       $ignore = 'no';
      }
// end referrer check.
// Decompile url variables to be placed into cookie
   if ($url == '') $url = 'Bookmark'; //if no referrer than must be direct or bookmarked.
   if($src == 'ov' & $ignore != 'yes') $url = 'Overture'; // edit to what you want to track
if($src == 'google' & $ignore != 'yes') $url = 'Google'; // edit to what you want to track
if($src == '' & $ignore != 'yes') $url = 'Natural Listing'; // edit to what you want to track
// set Cookies & Count if not linked from internally
   if ($ignore != 'yes') {
if( $visitcount == "") $visitcount = 1;  // Start Counter (if cookie doesn't exist start at 1)
else $visitcount++; // End Counter  
setcookie("visits",$visitcount,time()+60*60*24*365,'/','www.yoursite.com'); //Never Expires
setcookie("referer",$url,time()+60*60*24*365,'/','www.yoursite.com'); //Never Expires
setcookie("keywords",$kw,time()+60*60*24*365,'/','www.yoursite.com'); //Never Expires
}// End set cookies
// Start Debugger
if ($debug == 'true') {
if (isset($HTTP_COOKIE_VARS["visits"])) print "Visit Cookie Written<br>"; // Check Cookie
     else print "Visit Cookie Not Written<br>";
if (isset($HTTP_COOKIE_VARS["referer"])) print "Referer Cookie Written<br>"; // Check Cookie
  else print "Referer Cookie Not Written<br>";
   if (isset($HTTP_COOKIE_VARS["keywords"])) print "Keywords Cookie Written<br>"; // Check Cookie
  else print "Keywords Cookie Not Written<br>";
print "This is visit number " . $visitcount;
print "<br> You Come from: " . $url;
print "<br> Linked from internal page? (Local Src) " . $ignore;
// Testing Links.... for best results put these links on an external site
print "<br><a href='cookie.php?src=ov&kw=testing+keywords'>link to test source and keywords</a><br>";
   print "<a href='cookie.php?src=ov'>link to test source</a><br>";
   print "<a href='cookie.php'>link to test no src & no keywords</a><br>";
}//End Debugger


?>



© 2002-2005 Flaxweb Network | Article Manager | Gimp Tutorials Library | RAD C++ Library | Free C/C++ Sourcecode |
Sites of interest : Web Design Blog | Swish Templates | Swishmax Ebook | Photoshop Templates | Gimp Tutorials | Text Forum | Make Money Online