Javascript version looks like this:
<script type="text/javascript" id="pap_x2s6df8d" src="https://URL_TO_PAP/scripts/trackjs.js"></script>
<script type="text/javascript">
PostAffTracker.setAccountId('default1');
try {
PostAffTracker.track();
} catch (err) { }
</script>
<?php //PapApi.class.php can be downloaded in the merchant panel at //Tools>Integration>API Integration>Download PAP API require_once 'PapApi.class.php'; // init session for PAP $session = new Pap_Api_Session("https://URL_TO_PAP/scripts/server.php"); // register click $clickTracker = new Pap_Api_ClickTracker($session); $clickTracker->setAccountId('default1'); //if you need to set customer's IP use this row, otherwise is used IP recognized from $_SERVER['REMOTE_ADDR'] //$clickTracker->setIp('123.456.789.1'); try { $clickTracker->track(); $clickTracker->saveCookies(); } catch (Exception $e) { } ?>
Warning: If you do not call this function, sales won't work.
If you do not wish to save cookies using javascript, you can use following code:
// save cookies $clickTracker->save3rdPartyCookiesOnly();
This code will save browser cookies only (cookies are saved by php script). Optional parameter for the save3rdPartyCookiesOnly() is cookie domain (this can save cookie under higher domain).
Warning: if you save 3rd party cookies only, all tracking (click + sale) will be working on one same domain only.
If you need to save the ID of the generated cookie for later use in S2S tracking for example you can use the following after try catch in the above code:
$clickTracker->getVisitorId();
After click is saved (method track() was called) you can use the information about the affiliate through which the click was made. Also you can use the information about the campaign and channel and display it on your site:
if ($clickTracker->getAffiliate() != null) { echo $clickTracker->getAffiliate()->getValue('userid'); // prints affiliate userid echo $clickTracker->getAffiliate()->getValue('refid'); // prints affiliate refid } if ($clickTracker->getCampaign() != null) { echo $clickTracker->getCampaign()->getValue('campaignid'); // prints campaign id } if ($clickTracker->getChannel() != null) { echo $clickTracker->getChannel()->getValue('channelid'); // prints channel id echo $clickTracker->getChannel()->getValue('channel'); // prints channel code echo $clickTracker->getChannel()->getValue('name'); // prints channel name }
// init merchant session for PAP
$session = new Pap_Api_Session("https://URL_TO_PAP/scripts/server.php");
if(!$session->login("MERCHANT_USERNAME", "MERCHANT_PASSWORD")) {
echo("Cannot login. Message: ".$session->getMessage());
}
Affiliate:
username
rpassword
firstname
lastname
parentuserid
dateinserted - date when affiliate joined the program
dateapproved - date when affiliate was approved
minimumpayout
note
photo
data1 - see Configuration -> Affiliate signup -> Fields
...
data25
Campaign:
accountid
rtype
rstatus
name
description
dateinserted
rorder
networkstatus
logourl
productid
discontinueurl
validfrom
validto
validnumber
validtype
cookielifetime
overwritecookie
countries
geocampaigndisplay
geobannersshow
geotransregister