Installing Share A Sale Tracking Code On Magento
I recently signed up to Share A Sale as an advertiser for an ecommerce website running on magento. Now, I am not a web developer or anything like that. I know how to install tracking codes on confirmation pages but having to enter proper dynamic variables to populate the dynamic order information is a bit to complex for me.

But as I was working on installing the code I found out that it was fairly simple to install share a sales’s the code, since shareasale.com did all the heavy lifting for me. They provided me with magento’s variables.
Before they provide you with the code to add to the confirmation page you need to select from a drop down what platform you are using for the website, once you select it, they generate the code for you and give you exact instructions of as to where on the page you should add your code.
Tracking code details for Magento
You will be marking changes to the following file:
/app/design/frontend/defualt//template/checkout/success.phtml
Find the line that reads:
<p><strong><?php echo $this->__('Thank you for your purchase!') ?></strong></p>and just below that line, add the following code:
<?php $_customerId = Mage::getSingleton('customer/session')->getCustomerId(); $lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId(); $order = Mage::getSingleton('sales/order'); $order->load($lastOrderId); $_totalData =$order->getData(); $_sub = $_totalData['subtotal']; ?> <img src="https://shareasale.com/sale.cfm?tracking=<?php echo $this->getOrderId() ?>&amount=<?php echo $_sub ?>&transtype=sale&merchantID=XXXX" width="1" height="1">
As you can see its as easy as 1, 2, 3. The only thing which you need to do is replace the XXXX with your account #.
Before adding your code please note the following “disclaimer” from magento
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
Kudos to shareasale.com for providing its users with the exact code and variables so that their advertisers can easily install the tracking code on to their websites.