With Analytics, GetClicky and other tracking tools, you can setup campaigns and the revenue associated with it. To track the revenue of all orders in Magento, you will have to include a bit of Javascript code on the checkout success page.
Edit the checkout/success.phtml file inside your template folder.
[php]
<?php
$order = Mage::getModel(‘sales/order’)->load(Mage::getSingleton(‘checkout/session’)->getLastOrderId());
// After this you can get various data from the order
// $subTotal = $order->getSubtotal();
// $order->getId(); //the id of the order
// $order->getIncrementId(); //the increment id of the order
$grandTotal = number_format($order->getGrandTotal(), 2); //grand total of the order
?>
[/php]
In case of GetClicky, the campaign revenue code will look as follows.
[php]
<script type="text/javascript">
var clicky_goal = { id: "112", revenue: "<?php echo $grandTotal; ?>" };
</script>
[/php]
Written by Gordon
Topics: Magento