Tracking CJ Commissions with Prosper202

by on May 3, 2010

Pin It

CJ + Prosper202 logosI 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 combine the two.

It’s actually pretty simple… just take the code from the CJ page, then the part where 202 is pinged from the SAS+202 post, and you get:

<?php
	$cDevKey = 'your-developer-key';

	$cURL = 'https://commission-detail.api.cj.com/v3/commissions?';
	$cURL .= 'date-type=event&';

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $cURL);
	curl_setopt($ch, CURLOPT_HTTPHEADER, array(
				  'Authorization: ' . $cDevKey,
				  'User-Agent: "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.15) Gecko/2009101601 Firefox/3.0.15 GTB6 (.NET CLR 3.5.30729)"'
				));

	curl_setopt($ch, CURLOPT_HEADER, false);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
	curl_setopt($ch, CURLOPT_TIMEOUT, 10);

	$cHTML = curl_exec($ch);
	if (curl_error($ch)) {
		echo "Curl error: " . curl_error($ch);
	} // ends if (curl_error($ch))
	else {
		$cXML = simplexml_load_string($cHTML);

		for ($i = 0; $i < count($cXML->commissions->commission); $i++) {
			$oCJCommission = $cXML->commissions->commission[$i];

			$cPostback = 'http://yourdomain.com/tracking202/static/gpb.php?amount=' . urlencode($oCJCommission->{'commission-amount'}) . '&subid=' . urlencode($oCJCommission->sid);
			$fpPostback = @fopen($cPostback, "r");
			if ($fpPostback !== false) {
				fclose($fpPostback);
			} // ends if ($fpPostback !== false)
		} // ends for ($i = 0; $i < count($cXML->commissions->commission); $i++)
	} // ends else from if (curl_error($ch))
?>

Cron this script (I have mine run every day about 7am) and you’ll see your CJ commissions in Prosper202

Was this post useful? Please share it with others:

Pin It

{ 5 comments… read them below or add one }

NJ Golfer May 3, 2010 at 5:21 pm

Eric,

Thanks for the quick post. I’ll let you know how this turns out. Now I have to figure out how to do crons on my Mac. Someone suggested Cronnix.

Reply

Panda October 25, 2010 at 5:07 am

I wonder what ever came of this.

Eric, got any info as far as this working properly? I might give it a go.

Reply

Eric Nagel October 25, 2010 at 5:50 am

What do you mean? It’s a full script. While I don’t use 202, I haven’t heard of this not working for anyone. Are you having a specific problem with it?

Reply

Marlon from NJ January 11, 2011 at 2:09 pm

Hello Eric,

Happy New Year. No doubt, this holiday stuff doesn’t stop you from chopping away in the Affiliate world. I have a situation, which I’m sure you’ve encountered. It involves Google Adwords and the major affiliate networks.

I know the subject script works for tracking converting keywords with CJ and prosper. I am starting to run some Google Content Network ads for CJ offers and I wonder how this can be configured in such a way to bypass Prosper202. (Nothing wrong with Prosper). The reason for this is you can see some extremely valuable metrics in the Google Adwords dashboard. If you create landing pages, you can dig down further and cross this data over to Google Analytics to obtain geo data as well as landing page visitor information (bounce rate, pageviews per visit etc.).

Most will recognize the fact that CJ and other large networks do not allow Affiliates to place conversion pixels/tracking tags on their pages. My goal here would be track these metrics:

Adgroup, keyword, ad name, placement (site where the click was made), cost per click etc.

Bear in mind these ads are run on the Content Network, hence the need to see placement data. I’d appreciate your thoughts on this . Perhaps this script can be modified to do this? Don’t know. I was going to send you an email but figured this is probably the best place to ask this type of question.

Reply

Eric Nagel January 13, 2011 at 7:18 pm

Hi Marlon,

If you can pull this data (“Adgroup, keyword, ad name, placement (site where the click was made), cost per click etc.”) from the HTTP_REFERER, then save the click to a database with an auto incrementing ID, then use that as the SID, you can track just as described.

It’s actually how I do tracking, as I personally don’t use 202

Reply

Leave a Comment

Previous post:

Next post: