Call us Toll-Free:
1-800-218-1525
Email us

 Sponsors

Tracking First Cookie vs Last Cookie

Dawn Rossi, 05-03-2008
When tracking affiliate IDs or SIDs, there are two popular methodologies you can choose from:

1. First Cookie

The first affiliate to refer traffic to your website earns credit for the sale.

Example:
Andrew refers Robert
Jim refers Robert
Robert buys
- Andrew earns the credit

2. Last Cookie

The last affiliate to refer traffic to your website earns credit for the sale.

Example:
Andrew refers Robert
Jim refers Robert
Robert buys
- Jim earns the credit

--

Choosing which methodology you would like to go with is strictly a business decision. Once you've made your selection, be sure to communicate this to your affiliates and motivate them accordingly.

Below are the two different scripts to implement first cookie vs last cookie tracking:

Track affiliate referrals by First cookie:


// If we have an affiliate ID cookie, use it
if (!empty($_COOKIE['aff_id'])) $aff_id = $_COOKIE['aff_id'];
else
// (No cookie)
// If we have an affiliate ID in the URL, use it
if (!empty($_GET['aff_id']))
{
$aff_id = $_GET['aff_id'];

// Save affiliate ID cookie for 90 days
@session_register("aff_id");
@
setcookie("aff_id",$aff_id,time()+3600*24*90,"/",".YOURDOMAIN.COM");
}

Track affiliate referrals by Last cookie:


// If we have an affiliate ID in the URL, use it
if (!empty($_GET['aff_id']))
{
$aff_id = $_GET['aff_id'];

// Save affiliate ID cookie for 90 days
@session_register("aff_id");
@
setcookie("aff_id",$aff_id,time()+3600*24*90,"/",".YOURDOMAIN.COM");
}
// If we have an affiliate ID cookie, use it
else
if (!empty(
$_COOKIE['aff_id'])) $aff_id = $_COOKIE['aff_id'];

Andrew, 06-01-2016
session_register() is no longer valid
so you must replace
@session_register("aff_id");

with :
$_SESSION['aff_id'] = $aff_id; only if u use sessions and you already start the session ( session_start();)
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions