Click tracking request data description

Post Affiliate Pro tracking is based on requests between the client (banner destination web page or "thank you page") and the server.

If it is the first request and the browser visitor cookie is not loaded, the server generates a new cookie value and sends it to the client as a response. JavaScript on the client will store the received cookie value in the browser and in the HTML5 local storage.

If the browser visitor cookie is loaded and inserted into the request parameter visitorId, then the response is empty, and the click or sale is saved under the affiliate recognized from the cookie.

Click Tracking Request

This request is sent from the click tracker to the Post Affiliate Pro server:

https://my_pap_url/scripts/track.php?visitorId=&accountId=&url=H_my_pap_url%2Ftests%2Fapi%2Fclick.php&referrer=&tracking=1&getParams=%3Fa_aid%3Dtestaff%26a_bid%3D11110001%26chan%3Dcode2&ip=127.0.0.1&useragent=Mozilla%2F5.0+%28Windows+NT+6.1%3B+WOW64%3B+rv%3A10.0%29+Gecko%2F20100101+Firefox%2F10.0

Request URL is your PAP/PAN URL to the file track.php in the scripts directory: 
https://my_pap_url/scripts/track.php

URL Parameters:

  • visitorId: Loaded from the browser cookie (leave empty if it doesn’t exist in the browser cookie, which is common for the first click). In PHP, use: @$_COOKIE['PAPVisitorId'];
  • accountId: For Post Affiliate Pro, you can leave this empty or set it to default1. For Post Affiliate Network, you need to set the account ID of a particular PAN merchant account.
  • url: URL to the script file where the script is running. For example, if your script is at https://my_url/tests/api/click.php, 'http://' is replaced with H_ and 'https://' is replaced with S_. 
    In PHP, you can get this from $_SERVER['HTTPS'] (for protocol), $_SERVER["SERVER_NAME"] (server name), and $_SERVER['PATH_INFO'] or $_SERVER['SCRIPT_NAME'] (script name).
  • referrer: Loaded from $_SERVER['HTTP_REFERER']; 'http://' is replaced with H_ and 'https://' is replaced with S_ (same as for the URL).
  • tracking: In click tracking, this contains the value: 1
  • getParams: Contains all GET parameters from the URL. For example, if the visitor uses the URL https://my_url/tests/api/click.php?a_aid=testaff&a_bid=11110001, then getParams will contain a_aid=testaff&a_bid=11110001 (in PHP, loaded from $_GET). Each parameter value is encoded with urlencode($value).
  • ip: Visitor IP; in PHP, this can be loaded from $_SERVER['REMOTE_ADDR'] or $_SERVER['HTTP_X_FORWARDED_FOR'].
  • useragent: Loaded from $_SERVER['HTTP_USER_AGENT'].

Response

The response after executing this request will contain the generated cookie (only for the first click if the cookie value of the parameter visitorId is empty). The response with the cookie looks like this:

setVisitor('b57b0406c5b9febba85ce10J1xJqsL8Z');

For subsequent visits or requests from the same visitor, the response will be empty.

If the response is not empty and you need to create a browser or HTML5 local storage cookie for this visitor, then, along with the PHP API tracking, there is JavaScript code added and executed by the browser:

echo '<script id="pap_x2s6df8d" src="https://my_pap_url/scripts/trackjs.js" type="text/javascript"></script>';
echo '<script type="text/javascript">setVisitor('b57b0406c5b9febba85ce10J1xJqsL8Z');</script>';

The JavaScript function setVisitor() from the file trackjs.js will create a browser cookie and an HTML5 local storage cookie with the name PAPVisitorId and the corresponding cookie value (in this case: b57b0406c5b9febba85ce10J1xJqsL8Z).

×