Prosper202 is a powerful affiliate marketing tracking software package, with the ability to give you your revenue, cost, and ROI on your PPC campaigns. But the true power is shown when you automate as much as possible.

I’ve previously written how to use the ShareASale API, but left it up to you to fill in the blanks. In this example, I’m going to show you how to automatically get your ShareASale revenues to post back to Prosper202.

Before we begin, make sure you’re read the first post I wrote, or else this one will go by quickly. What this script does is fetches your sales from the previous day and submits the values and SIDs to your Prosper202 installation.

$dYesterday = date("m/d/Y", time()-86400);

$cURL = '' . $dYesterday . '&dateEnd=' . $dYesterday . '&XMLFormat=0';
// $cURL = 'sas.csv';

$fp = fopen($cURL, "r");
if ($fp) {
	$rsMap = array();
	while (empty($rsMap) && (($rsHeadings = fgetcsv($fp, 1000, "|")) !== FALSE)) {
		if (md5(serialize($rsHeadings)) != '5b448a7bdbeea0be7d7f758f5f8ee90b') {
			// echo(md5(serialize($rsHeadings)) . "\n");
			// print_r($rsHeadings);

			while (list($nIndex, $cColumn) = each($rsHeadings)) {
				// echo("$cColumn => $nIndex<br />\n");

				$cColumn = ereg_replace("\(.+\)", "", $cColumn);

				$rsMap[$cColumn] = $nIndex;
			} // ends while (list($nIndex, $cColumn) = each($rsHeadings))
			// print_r($rsMap);
		} // ends

		[Trans ID] => 0
		[User ID] => 1
		[Merchant ID] => 2
		[Trans Date] => 3
		[Trans Amount] => 4
		[Commission] => 5
		[Comment] => 6
		[Voided] => 7
		[Pending Date] => 8
		[Locked] => 9
		[Aff Comment] => 10
		[Banner Page] => 11
		[Reversal Date] => 12
		[Click Date] => 13
		[Click Time] => 14
		[Banner Id] => 15
	while (($rsStatData = fgetcsv($fp, 1000, "|")) !== FALSE) {
		// print_r($rsStatData);
		if (
			(md5(serialize($rsDeal)) != '5b448a7bdbeea0be7d7f758f5f8ee90b') &&
			($rsStatData[$rsMap['Commission']] > 0) &&
			!empty($rsStatData[$rsMap['Aff Comment']]) &&
			($rsStatData[$rsMap['Aff Comment']] != "none")
			) {

			$cPostback = '' . urlencode($rsStatData[$rsMap['Commission']]) . '&subid=' . urlencode($rsStatData[$rsMap['Aff Comment']]);
			// echo("$cPostback\n");
			$fpPostback = @fopen($cPostback, "r");
			if ($fpPostback !== false) {
			} // ends

		} // ends if (!empty($rsDeal))

	} // ends while (($data = fgetcsv($fp, 1000, "|")) !== FALSE)
} // ends if ($fp)

The script creates a URL to grab yesterday’s stats, creates an array of the column headers ($rsMap), loops through the rest of the stats and if:

  • the line isn’t empty
  • the Commission is greater than 0.00
  • there is a SID
  • the SID is not “none”

then it pings your Prosper202 installation and updates the database with the commission for that SID.

Most of the code in this script is just reading the CSV file and getting the column names in place. The real work is done in lines 55-60.

Remember you’re limited to 200 API calls per month with ShareASale, so schedule this script to run daily (via cron).

If you have any questions, please leave them in the comments. And if you haven’t done so already, signup with ShareASale!

7 Comments » for Tracking ShareASale Commissions with Prosper202
  1. Very nice article and script buddy.

  2. I was looking at this script again. It’s very quaint, and I am looking at implimenting. Now, obviously this has to be edited with one’s own SAS AFF ID and P202 domain.

    I do have a question about &token=yourtoken. What token are you referring to?

    Also, the generated SAS CSV if you will, has commission amounts, and I see you are including that on the postback query. Does this amount override what one has set up in their P202 for commission?

    Another thing, why are you checking if the md5 is NOT “5b448a7bdbeea0be7d7f758f5f8ee90b” twice?

    I already want to tweak this php code to include $_GET parameters to use multiple aff IDs or P202 install domains. I just don’t like having to code the sanitising of said variables. Is this what Stats202 does? Hmm.

    But I will hold off, as there is a new Prosper202 version in the works.

  3. Eric Nagel says:

    Hey David – I’ll walk you through it on Skype to answer your questions

  4. Thanks for the walk-through.

    This script doesn’t need to be CHMOD to 744 or 755 or something, right? I guess I’ll find out on my own.

  5. Thanks for this Eric. Is there anything we need to do within Prosper202? I have the script uploaded to my server and a cronjob scheduled every 8 hours.


  6. Eric Nagel says:

    Hey Robert – nothing has to be done in P202. However, only run this once / day, as it grabs “yesterday’s” stats. So, running every 8 hours will give you “yesterday’s” stats 3x / day. Just run it about 4am or so

  7. Eric,

    Thanks for this! I just got around to uploading this and wanting to let you and others know that and it works perfectly!

1 Pings/Trackbacks for "Tracking ShareASale Commissions with Prosper202"
  1. […] got a call today from a guy in NJ looking to track CJ sales with Prosper202. He saw my post on Tracking ShareASale Commissions with Prosper202 and another post on using the Commission Junction Web Services and wanted some info on how to […]

Leave a Reply

Your email address will not be published. Required fields are marked *