The topic of debugging sale / action tracking requests is quite extensive since there are many different integration approaches which could be sending tracking requests differently into the application and it is hard to write a comprehensive and complete guide on how to debug every single option.
In case you have integrated PayPal buttons and these do not track please follow PayPal button debugging article
- If you wish to find out why your sale or Action Commissions aren't generating commissions in Post Affiliate Pro then please first follow the guide for debugging using Sale requests log.
- You should continue reading only if you have already tried the Sale requests log article and found out that your sale tracking code isn't communicating with your installation or your PAP version is older and doesn't include Sale requests log option.
When you are sure that your website doesn't communicate with your Post Affiliate Pro so that you can't see any log in Tools->Sale requests log nor in Tools->Event logs and that your clicks are being tracked it is time to find out whether your sale tracking code actually executes. For this you are going to need a browser with developer tools. Most browsers have developer tools and are usually opened by pressing F12. If you don't know how to open developer tools in your browser then please use Google to find some guide.
Preparations and required knowledge
Make a click and get your cookie's ID
Click an affiliate link and make sure your click was tracked in Transactions->clicks list (remember there might be 5-15 minutes delay due to cron job). This is not a mandatory step but if you wish to get a commission saved it is important to have a valid cookie and be referred by an affiliate.
After you have your click saved you can check in your browser what is the ID of your cookie. You need to find the PAPVisitorID cookie and look for its content. It is going to be a 32 character string of letter and numbers. Copy it and go to Tools->Visitor affiliates in your merchant panel and search for the ID you copied from cookie. If you find it then you were referred by an affiliate. There should be a record which is marked as Actual and this record should govern how the commission will be saved, under what affiliate, campaign and so on.
Note down the ID of the cookie for later use.
Get yourself familiar with hashed names of your tracking scripts
Go to your merchant panel Tools->Sales/Leads tracking and check the checkbox for "Hash script file names" (if it isn't checked already) and note down the names of the scripts, we are interested in the strings of letters and numbers right after /scripts/ as depicted on the screenshot:
From the screenshot we have found out that the hashed variants are 3j05xk1 and 3s05xk1. Note these 2 down and notice that they differ in just one letter - "j" and "s". Now we need to get a 3rd script name which will use "r" instead so in my example it would be 3r05xk1.
Remember that this string is different for each user but all strings will contain either "j" or "s" or "r" in case of the 3rd one in which we are interested.
Proceed with the actual order
Proceed with a purchase on your website and before finishing the order process open developer tools in your browser, usually by pressing F12 on your keyboard, and go to Network tab where you can see what URLs are called when a page is loaded. Enable persistent/recording mode in the developer tools so that the developer tools are not discarded and keep recording even if you get redirected to another domain.
With the developer tools opened and switched to Network tab finish the order so that you get redirected to the thank you page where your sale tracking code should execute.
After the thank you page is loaded you should see in the developer tools that a call to your Post Affiliate Pro installation has been made. The call should be made to one of these scripts:
- track.php (or its hashed counterpart which uses "r" in its name so 3r05xk1 from the example above)
- sale.php (or its hashed counterpart which uses "s" in its name so 3s05xk1 from the example above)
You should be aware that you can see the call to track.php (or its hashed counterpart in this example 3r05xk1) being made twice. The script is used for both click tracking and sale tracking code so if you have both codes on your thank you page then it would be called twice. The only way how you could differentiate between them is to copy their whole URL with all the parameters
and to look whether the called URL contains a string like "sale=".
Click tracking call example:
Sale tracking call example (notice the sale= parameter in it):
- If you can see such call in your developer tools with status 200 OK then you can be sure that it sends the requests to PAP and you should see it in Tools->Sale requests log and Tools->Event logs (if you have logging enabled).
- If you can't see the call in developer tools then try opening source code of the thank you page (by right clicking into the page and selecting View source code or by pressing ctrl+U on your keyboard) and try to search in the source code using ctrl+f shortcut. Search for either one of the following queries:
Click tracking will also contain pap_ but it won't look like the sale tracking code . So if any of the searches yield a result make sure that it is the sale tracking code.
Now even if you see the code on the page it still doesn't mean it is executed. There can be several things wrong in the added coded which could prevent it from executing:
- Wrong URL address in the script, not pointing to your PAP
- Typo in the code or added paragraph <p> or CDATA tags in the code
- code added elsewhere then inside <body> section
The purpose is to find the code which you have used and compare it with the code in your merchant panel Tools->Integration->Sale/lead tracking to find out what might be the problem. Fix the code and double check by reloading thank you page (if your shop allows that) or better yet make a new order.
When the request is executed but commission isn't saved
If you can't use this one or you want to find out more details about how exactly was the commission saved you can either use direct debugging or debugging with event logging.
Using direct debug requires you to do the above steps to capture the request URL and add &PDebug=Y parameter to it (debugging via this parameter has to be enabled first under Configuration->Event logging!).
Example of track.php (it's hashed variant) with PDebug=Y
Example of sale.php (it's hashed variant) with PDebug=Y
When you open the link of the request with &PDebug=Y in your browser it will print you the logs with the whole process of saving of the commission so read the messages line by line to understand how was affiliate selected, how was campaign selected, what amended the commission and so on. To understand the stopping messages you can consult the list of most common error messages.
Debugging with Event logs
Before placing a test order go to your merchant panel and navigate to Configuration> Event logging where you need to check the checkbox for "Sales" and save it in order to enable logging. Now, make a test sale and turn the debugging off. In case you are using cron job on your server (hosted with us customers always do) it will take 5-15 minutes before the logs are populated. You can speed this up by forcing the tracking requests to process.
Then navigate to Tools> Event logs and in the upper left corner in Search in select Sale debug. On the below screenshot are highlighted the most important things:
Each commission saving starts with "Saving sale/action" and contains the request which was sent so even the order ID for which you can directly search using the Search box. When you get a result which starts with Saving sale/action you should copy its Group ID (if you don't see it you need to Edit view and add the column to your view) and then search for this group ID - it will list all the logs for saving of the particular commission. So just read through all the messages until the end to get an idea of how the commission was being saved and find out what went wrong. You can consult the list of most common error messages.