3rd Party Conversion Tracking
Magento Commerce has the ability to track eCommerce sale with Google Analytics out of the box (more on that in a future post). Something that a lot of merchants struggle with is how to set up conversion tracking for other tracking software or comparison shopping engines.
![]()
How To
Here is an easy hack to track conversions for Shopzilla, PriceGrabber and the likes:
Open the file: app\design\frontend\XXXX\XXXX\template\checkout\success.phtml
At the end of the file, add the following code, this will create two variables with the order number and the order total:
<?php
//Get Order Number & Order Total
$order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$amount = number_format($order->getGrandTotal(),2);
?>After the above code snippet, copy and paste the tracking code from the third party analytics software of comparison shopping engine. Insert the following variable where they suggest placing the order ID and the order total:
<?php echo $amount; ?> // Order Total <?php echo $this->getOrderId() ?> // Order Number
Here is a code example for the Shopzilla conversion tracking tool:
<script language="javascript"> var mid = 'XXXXX'; // Your Shopzilla Merchant ID var cust_type = ''; var order_value = '<?php echo $amount; ?>'; // Order Amount var order_id = '<?php echo $this->getOrderId() ?>'; //Order Number var units_ordered = ''; </script> <script language="javascript" src="https://www.shopzilla.com/css/roi_tracker.js"></script> <script language="JavaScript" src="https://eval.bizrate.com/js/pos_193511.js" type="text/javascript"></script>
Image Credit: Search Engine Journal

Hey, thanks for the article! Any insight on how to include tracking code for MS AdCenter (Bing) in Magento? I tried putting it into app/code/core/Mage/Checkout/Block/Onepage/success.php but it throws an error message after checkout.
Hi autoguy
Please see the above article — you will want to add the code in: app\design\frontend\XXXX\XXXX\template\checkout\success.phtml
–M
Thanks – but I’m still getting an error message:
Parse error: syntax error, unexpected ‘<' in l/app/design/frontend/default/default/template/checkout/success.phtml on line 78
any insight?
Hey, I actually found a typo in my code, it’s working now, so thanks a lot!
Glad you got it working.
tried your code but no result :(
the problem is with amount
thanks for this useful post! i did as you told us, and it works now!
thanks again!
HI.
I am working on prestashop e-commerce solution.
Can you advice in wich file i am suposed to included your code ?
Prestashop is written in smarty language and i couldn’t found where to put your code.
Is it into : Theme/mytheme/order-confirmation.tpl ?
Thanks for your reply
Regards
Fabien,
Unfortunately, I am not familiar with Prestashop.
Hi,
thanks for the information. Unfortunately, the code doesn’t work for 1.4.2! Do you have a solution for 1.4.2?
Thanks, Kurt
Do you know how to pull specific items for tracking?
Didnt work for me in magento 1.6.1 . Ill try another solution now, I will get back at you!
Grtz from Holland
I just tested on 1.5.1.0 and it works properly. Not sure about 1.6.1