Get Help & Support

Magento Purchase Event Tracking

Note: The below instructions require knowledge in editing Magento template files, if you don’t know how to do this it is advised to get a web developer to assist you.

  1. Copy success.phtml from app/design/frontend/base/default/template/checkout/ to app/design/frontend/default/yourtheme/template/checkout/ replacing “yourtheme” with your theme name.
  2. Open the newly created file success.phtml locatedat app/design/frontend/default/yourtheme/template/checkout/ in a code editor of your choice.
  3. Add the following code in your success.phtml:
<?php $order = Mage::getModel("sales/order")->loadByIncrementId($this->getOrderId()); ?>

<script>
!function(p,i,x,e,l,j,s)
{if(p.spq)return;l=p.spq=function(){
l.callMethod?l.callMethod.apply(l,arguments):l.queue.push(arguments);};
if(!p._spq)p._spq=l;l.push=l;l.loaded=!0;l.version="1.0";l.queue=[];
j=i.createElement(x);j.async=!0;j.src=e;s=i.getElementsByTagName(x)[0];
s.parentNode.insertBefore(j,s);}(window,document,"script",
"https://api.successpath.ai/pixel.js");

spq("conversion", {
 value: "<?php echo $order->getBaseGrandTotal() ?>",
 type: "purchase",
 currency: "<?php echo $order->getOrderCurrencyCode(); ?>",
});
</script>

4. Save the file.

5. You are now setup to start tracking purchase events in your Magento store.