Sometimes our customers need to track different actions which happen only on the server side and not on the client side so they can't execute JavaScript integration code or the HTML pixel on website. In these cases they would need to use S2S tracking. There are different approaches how this can be done:

- either with our PHP API with Pap_Api_SaleTracker or with Pap_Api_Transaction. Pap_Api_SaleTracker is a better option since the commission would go through regular tracking process in the software, so fraud protection wouldn't be ignored, commissions with wrong details wouldn't be saved, some fields like time of the commission and so on would be populated automatically. Pap_Api_Transaction on the other hand isn't really tracking API, it is API for directly inserting the desired data as commission, in this approach you need to define much more details and commission added like this would completely skip tracking.

- or by simply calling URL with GET parameters in which you can define the details of the commission which will be saved. This article is going to describe this second option.

 

There are 2 possible scenarios depending on whether you can integrate the landing page to which your affiliates will be sending the customers with the Javascript click tracking integration code which you can get in your merchant panel Tools->Integration->Click tracking integration or not:

 

Scenario 1: You can add javascript code to the landing page.

First thing to set up is to make sure that your PAP uses New Style links. So go to Configuration->Tracking settings section of your merchant panel and make sure that New Style links are set up there. Also go to Campaigns->Campaigns manager and go through all your campaigns and make sure that the linking method used in your campaigns is set to "Default" method so it is taken from Configuration->Tracking settings.

Your landing page will need to be integrated with the click tracking code so you can get the required code from your merchant panel Tools->Integration->Click tracking integration section and place the code for example into the footer template of your website. When customer lands on an integrated website then a browser cookie called PAPVisitorId will be created and depending on whether the customer stays on the same domain or clicks through to some other domain you have 2 subscenarios:

subscenario A: customer stays on the same domain

In this case you should have no problem to capture the ID of the cookie via PHP right after the customer gets to some other page on your domain via PHP variable $_COOKIE["PAPVisitorId"] . You will need to save this cookie for the later call which will save the actual commission.

subscenario B: customer click through some other domain right after landing

In this case you aren't able to directly capture the cookie ID since PHP would run before the cookie was created so you would need to resend the cookie ID to this other domain and capture it via PHP there. To do this you can use another piece of javascript code which will read the cookie and either write it to some HTML input field or to a href URL after selected parameter. Here is an example code with the 2 required functions:

<script id="pap_x2s6df8d" src="https://URL_TO_PostAffiliatePro/scripts/salejs.php" type="text/javascript">
</script>
<script type="text/javascript">
PostAffTracker.setAccountId('default1'); //use this line for Post Affiliate Network account ID of your merchant
PostAffTracker.writeCookieToCustomField('id_field');
PostAffTracker.writeCookieToLink('id_field', 'papCookie');
</script>

If you have used the second function PostAffTracker.writeCookieToLink('id_field', 'papCookie'); then the cookie will be added to the URL the customer clicked after papCookie URL parameter so you should be able to get it with PHP on the other domain in variable $_GET["papCookie"] so you can save it for later use.

On the other hand if you will be tracking the actions of registered users then you could use function PostAffTracker.writeCookieToCustomField('id_field'); somewhere on the registration page to write the cookie into some hidden input field and store it for each new customer to know which affiliate referred him and to be able to later use the cookie in the tracking call.

If this sounds complicated or unreliable then you can skip to Scenario 2 and subscenario B.

Scenario 2: You can NOT add javascript code to the landing page.

Depending on whether you mind that your affiliates will be promoting links pointing to your Post Affiliate Pro installation or not there are again 2 possible scenarios:

subscenario A: you do NOT mind links pointing to your Post Affiliate Pro

First thing to set up is to make sure that your PAP uses Standard (Redirect) links. So go to Configuration->Tracking settings section of your merchant panel and make sure that Standard (Redirect) links are set up there. Also go to Campaigns->Campaigns manager and go through all your campaigns and make sure that the linking method used in your campaigns is set to "Default" method so it is taken from Configuration->Tracking settings.

In the Destination URL of your banners and in the Main site URL in Configuration->Tracking settings affiliate links you need to add some parameter in which you will have the ID of the generated cookie and add to it {$visitorid} variable so for example ?cookie={$visitorid} will be added to each Destination URL. When this is done PAP's click.php script which creates the browser cookie for visitor will also fill in its value to the destination URL parameter so you can easily capture it from GET parameters via PHP variable $_GET["cookie"] for later use.

subscenario B: you do mind links pointing to your Post Affiliate Pro

In this case you will use New Style links exactly as in scenario 1 so read there on how to set those up. Affiliate links in this case might consist of the following parameters which you might need to capture to provide correct details for your affiliates in their reports:

  • a_aid - this parameter stores the affiliate ID
  • a_bid - stores the banner ID based on which also the campaign will be recognized
  • a_cid - might be used in special cases to pass the campaign ID directly in the affiliate link.
  • chan - stores the channel code which your affiliate added to the link
  • data1 - stores custom value added by your affiliate to the link
  • data2 - stores custom value added by your affiliate to the link

You would need to capture all these GET parameters, if they are set for later use. To read more about channel and data1 and data2 and to understand for what they are used exactly go here.

Executing the actual call

Now once you have the cookie ID or the URL parameters saved (depending on the scenario you followed) you can use those in a call to PAP tracking URL.

If you saved the cookie ID then first you need to realize that the cookie contains both the AccountId (first 8 characters) and the visitorId (last 32 characters), so you need to split it before you use it in the URL call:

https://URL_TO_PostAffiliatePro/scripts/sale.php?TotalCost=120.50&OrderID=ORD_12345XYZ&ProductID=test+product&visitorId=Last32CharactersOfTheSavedCookie

PAP will then search for the cookie ID in its database and save the commission to the affiliate and campaign under which this cookie ID was generated.

If you have instead saved the URL parameters directly from the URL then your call would look like this:

https://URL_TO_PostAffiliatePro/scripts/sale.php?TotalCost=120.50&OrderID=ORD_12345XYZ&ProductID=test+product&AffiliateID=a_aid&BannerID=a_bid&CampaignID=a_cid&ChannelID=chan&data4=data1&data5=data2

PAP will then take the affiliate for whom the commission should be saved from AffiliateID parameter and campaign under which it should be saved either from CampaignID if used or BannerID if campaign ID wasn't defined. More about recognizing of campaigns can be read here. You can also read about all the available variables which can be used in such a call to PAP here.

Of course if you are using Post Affiliate Network and the cookie was created for some specific merchant then you also need to pass his ID in this call in AccountId parameter.

Conclusion

Using the ID of the cookie in the actual sale call would be better since in this way the sale commission is tied with the click and you can see how did the clicks which led to this commission looked like. Besides that the data1 and data2 SubID parameters used by the affiliates will be also saved in the First click data 1/2 or Last click data 1/2 fields instead of in the actual sale data fields. Sale data fields are limited to 5 fields and you might use them for other sale related data.

One important thing to realize is that saving the commission like this will save your server's IP in the commission so if you would want the customer's IP instead for any reason then you should add to the commission saving also the &ip= parameter in which you should add the IP of the customer which you will need to save first.

×