How to assign a non-referred customer to a 'default' affiliate

Sometimes the merchants want to make sure, that affiliate does NOT get a commission for referring a customer, if this customer was on merchant's website before.
In other words, this guide is useful if you don't want to give commission for unreferred visitors (customers) to other affiliates whose link might be clicked by the unreferred visitor later in the future. 

You will achieve the desired effect only if "Overwrite cookies" option from Cookies configuration is disabled !

Also, this method works only if you are using New style, Anchor or Direct links. 

How it works: 
If a customer for the very first time in the past visited merchant's website WITHOUT any affiliate link, then the particular customer should be assigned to some kind of default affiliate (the merchant's default affiliate), so that no other affiliate who's link is clicked after that earns a commission for this particular customer.

How to make a setup: 
This is possible only with the PHP API tracking.
You need download the PapApi.class.php file directly from the merchant panel: Tools > Integration > API Integration > Download PAP API

Then, instead of default clicks tracking code inserted in your website, use this one:

<?php
include ("PapApi.class.php");
$session = new Pap_Api_Session("https://www.yoursite.com/scripts/server.php")
$clickTracker = new Pap_Api_ClickTracker($session);

//if the customer was referred by an affiliate save the cookies 
$clickTracker->track();
$clickTracker->saveCookies();
//if there was no referrer, then save the cookies to a default affilite of yours
if ($clickTracker->getAffiliate() == null) {
    $clickTracker->setAffiliateID('testaff'); //referral id of the default affiliate
    $clickTracker->track();
    $clickTracker->saveCookies();
}
?>
NOTE:
I. if you have a site of really high traffic, then this code may slow down your site.
II. the 'www.yoursite.com' in the code should be replaced by the real URL leading to your installation of Post Affiliate Pro
×