Difference between revisions of "Integrating PayPal Commerce Tracking"

From Market Ruler Help
Jump to: navigation, search
(first)
(No difference)

Revision as of 17:26, 20 June 2012

PayPal integration with Commerce Tracking is somewhat complex due to the fact that:

  • PayPal transactions occur solely on their domain https://www.paypal.com/
  • PayPal does not allow any third-party software, scripts, or image pixels to be installed as part of their commerce accounts, and ...
  • PayPal only allows "behind-the-scenes" notification of transaction success using their API called PayPal IPN

That said, ConversionRuler has a solution which works with PayPal.

Setting up your PayPal form

First, you need to send PayPal enough information so that ConversionRuler can uniquely identify the transaction and original landing data. To do this, you solely need to pass the ConversionRuler Cookie which is stored in the JavaScript global variable crcookie.

To do so, in your PayPal form, do the following:

<script type="text/javascript">
var craction = 3;
</script>
<form method="post" action="https://www.paypal.com/cgi-bin/webscr" name="paypal">
... add the following between the form tags ...
<script type="text/javascript">
document.write('<input type="hidden" name="custom" value="siteid=' + siteid + '&amp;crcookie=' + crcookie + '&amp;craction=' + craction+'" />');
</script>
</form>

Please note the above code uses single quotes and double-quotes - they are not the same, so please cut and paste carefully.

This passes the ConversionRuler cookie, site, and action code to PayPal for final processing when the transaction is complete.

Connecting from PayPal IPN

Once the visitor goes to PayPal, the only method of communication is via PayPal IPN. You can use ConversionRuler's fault-tolerant servers for this notification, but most likely, your server will have its own IPN software which you'll need to hook into.

If you want to use ConversionRuler's IPN gateway, the URL is as follows:

https://www.conversionruler.com/bin/paypal

Alternatively, you can parse the custom variable yourself in your own IPN gateway and pass it to conversionruler. It can be passed directly to ConversionRuler's tracking script:

<?php
/* This is your custom IPN processing file */
... regular IPN tracking ...
$custom = isset($_REQUEST['custom']) ? $_REQUEST['custom'] : null;
if ($custom) {
    $custom .= "&cramount0=" . urlencode($_REQUEST['mc_gross']);
    $custom .= "&crtext0=" . urlencode($_REQUEST['txn_id']);
    file_get_contents("https://www.conversionruler.com/bin/tracker.php?" + $custom);
}

The above code notifies our server, passes the total amount and the transaction ID, and records the action as originally specified. Note that your PHP configuration on your server must support allow_url_fopen which is generally available on most PHP servers.

If your IPN gateway is written in another language such as ASP, Perl, or Java then you can use a similar method to pass the parameters onto our servers.

For more information about PayPal and integration with PayPal IPN, contact MarketRuler Support.