UltraCart - Shopping Cart

Single Transaction Tracking

JavaScript Based Tracking

UltraCart has already built a tutorial on how to place Pixels like the ones that LinkTrust provides. Take a look at this article: UltraCart Pixel Configuration Tutorial.

Recurring Transaction Tracking

The purpose of setting this up is to allow affiliates to get credit for recurring transactions over a period of time. To do this, we make use of the AFID Pixel Post feature in LinkTrust. Note that this method of tracking does not allow the firing of affiliate pixels.

The method we are going to use to accomplish this is the XML Postback feature in UltraCart. You can learn more about it here: UltraCart XML Postback. That Postback will post to a hosted PHP script that will then interact with LinkTrust.

Step 1:

To start, you will need to enable AFID Pixel Posts on the campaign that you would like to track. To do so, go into the campaign's settings and under Tracking Options, click "Allow Server-Side Postbacks via AFID."

Step 2:

Next, you need to pass your AFID and CID in to UltraCart using a Custom Field. UltraCart has a detailed explanation on how to do so here: Passing Custom Fields to UltraCart During the Checkout .

Step 3:

Now you will need to create a PHP script that will act as a liaison between LinkTrust and UltraCart. This script will receive the XML from UltraCart, parse it out, and send the necessary information back to LinkTrust.

Example PHP code is provided at the bottom of this page. Though for this to work, there are some lines you will need to change.

First you will need to replace 

$pixel_url = "http://tracking.com/pixel.track";

with your current AFID Pixel Post URL. You can get the URL using the Link Generator under the campaigns settings.  After choosing a campaign and affiliate, click the "Generate Link(s)" button.  Choose "AFID Pixel Post" as the confirmation pixel type and copy the code in the text box.

Depending on how you set up Step 2, you may need  to change the following lines to match the values you are using to pass in as the AFID and CID.

$afid = $order->getElementsByTagName("custom_field_3")->item(0)->nodeValue;
$cid = $order->getElementsByTagName("custom_field_4")->item(0)->nodeValue;

Step 4:

You now need to host the PHP script that you have created. You will need a URL to access the file such as http://example.com/UltraCartXML.php.

Step 5:

Enter the URL to your PHP file into UltraCart in the XML Postback area. See UltraCart XML Postback for more detailed instructions.

You're done!

Transactions from here should show as AFID Pixel Post in your transaction details.

This is the example PHP code, which is modified from the example prodvided by UltraCart here.

// Copyright (C) 2009 BPS Info Solutions, Inc.
// This software is licensed under the CC-GNU LGPL version 2.1 or later.
// Full license is available at http://creativecommons.org/licenses/LGPL/2.1/
// Sample implementation to parse the data sent by UltraCart when using the
// XML Post Back functionality.
// Read in the XML document from the post data
$xml_document = file_get_contents('php://input');
// Parse the XML Document into a DOM Object
$doc = new DOMDocument();
// Now let's extract and echo out some of the key fields.
// There should be only one export element, but we're doing this
// the proper way just in case.
$exports = $doc->getElementsByTagName("export");
foreach ($exports as $export) {
    // I'm pretty sure that there is only one order, but we'll
    // do it this way just in case.
    $orders = $export->getElementsByTagName("order");
    // Now let's iterate through the order object and grab the LT Values
    // fields.
    foreach($orders as $order) {
        // Grab all of the pertinent info
        $order_id = $order->getElementsByTagName("order_id")->item(0)->nodeValue;
        $subtotal = $order->getElementsByTagName("subtotal")->item(0)->nodeValue;
        // You may need to change these from custom_field_3 and custom _field_4
        // to whatever you are passing it in as
        $afid = $order->getElementsByTagName("custom_field_3")->item(0)->nodeValue;
        $cid = $order->getElementsByTagName("custom_field_4")->item(0)->nodeValue;
        $pixel_url = "http://tracking.com/pixel.track";
        /*Here we are passing the Ultracart (UC) info like so:
          - UC order_id as LT MerchantReferenceID
          - UC custom_field_3 as LT AFID
          - UC custom_field_4 as LT CID
          - UC subtotal as LT TotalSales
         If you have addition parameters add them to the end of the next line
         like so:  . "&otherinfo=yes&Savecookie=x";
        $pixel_url = $pixel_url . "?CID=" . $cid . "&MerchantReferenceID=" . $order_id . "&TotalSales=" . $subtotal . "&AFID=" . $afid;
        // The file_get_contents() function happens to do a GET request
        // which is exactly what I need for LT. I don't actually
        // need the contents, so I just leave the variable alone
        $response = file_get_contents($pixel_url);
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.