Eric Nagel

Eric Nagel

CTO, PHP Programmer, Affiliate Marketer & IT Consultant

Tracking CJ Commissions with Prosper202

I have been, or can be if you click on a link and make a purchase, compensated via a cash payment, gift, or something else of value for writing this post. Regardless, I only recommend products or services I use personally and believe will be good for my readers.

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

Comments
  • NJ Golfer
    Posted May 3, 2010 5:21 pm 0Likes

    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.

  • Panda
    Posted October 25, 2010 5:07 am 0Likes

    I wonder what ever came of this.

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

    • Eric Nagel
      Posted October 25, 2010 5:50 am 0Likes

      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?

  • Marlon from NJ
    Posted January 11, 2011 2:09 pm 0Likes

    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.

    • Eric Nagel
      Posted January 13, 2011 7:18 pm 0Likes

      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

  • John
    Posted January 8, 2013 4:41 am 0Likes

    What if I need to delete some part of the subids before posting back to prosper how can I do that? I know it should be done here: ‘&subid=’ . urlencode($oCJCommission->sid);

    I use subids for some extra information beside the subid so If i update it right away it will not be the subid need to remove some part of it first. It’s really useful so if you can help me it will be much appreicated!

    • Eric Nagel
      Posted January 8, 2013 7:19 am 0Likes

      Hi John,

      Yes, you’d have to work with $oCJCommission->sid and pull out the part you want. Without knowing how you built your SID, I can’t tell you exactly how to parse it.

  • John
    Posted January 8, 2013 2:03 pm 0Likes

    It’s pretty simple need to just remove 508 at the end of the subid I tried to do this the following way Is it correct?
    for ($i = 0; $i commissions->commission); $i++) {
    $oCJCommission = $cXML->commissions->commission[$i];

    $subidcj = $oCJCommission->sid
    $newstr = str_replace(“508”, “”, $subidcj);
    $cPostback = ‘http://yourdomain.com/tracking202/static/gpb.php?amount=’ . urlencode($oCJCommission->{‘commission-amount’}) . ‘&subid=’ . urlencode($newstr);

  • peter
    Posted October 9, 2013 11:03 pm 0Likes

    Is tracking comish junction with prosper202 really this complicated? Is there a simple tracking solution available that does not coding?

    • Eric Nagel
      Posted October 27, 2013 9:12 pm 0Likes

      Nope – they don’t have a postback pixel for affiliates, so you have to use the API if you want to automate it.

Leave A Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.