May.03

Tracking CJ Commissions with Prosper202

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

How To & Tips
Share this Story:
  • facebook
  • twitter
  • gplus

Comments(11)

  1. NJ Golfer
    2407 days ago

    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.

  2. Panda
    2233 days ago

    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
      2233 days ago

      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?

  3. Marlon from NJ
    2154 days ago

    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
      2152 days ago

      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

  4. John
    1427 days ago

    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
      1427 days ago

      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.

  5. John
    1426 days ago

    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);

  6. peter
    1152 days ago

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

    • Eric Nagel
      1134 days ago

      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

Comment