Integrating Magento
From Wiki
Contents |
Introduction
Magento is a feature-rich eCommerce platform built on open-source technology that provides online advertisers with unprecedented flexibility and control over the look, content and functionality of their eCommerce store. Magento’s intuitive administration interface features powerful marketing, search engine optimization and catalog-management tools to give advertisers the power to create sites that are tailored to their unique business needs.
Designed to be completely scalable and backed by Varien's support network, Magento offers companies the ultimate eCommerce solution
How to: Setup Affiliate Window tracking with Magento
The Affiliate Window tracking code will need to be placed on your checkout success page - success.phtml. The success.phtml file can be found at the following location:
/var/www/html/magento/app/design/frontend/base/default/template/checkout/success.phtml
You need to use PHP to add the values required to the success.phtml file and also populate the variables within the Affiliate Window tracking code.
3rd Party Modules
You can purchase a module which has been created by a 3rd party - Juno Media here.
After the module has been set-up, it's possible to trigger automatic creation of an XML datafeed by using a URL provided by Juno.
The generated feed can then be found by adding the following to the end of the main URL:
/media/AffiliateWindow.xml
Sample Code Example
The sample code below has been setup with the PHP code needed to populate the tracking tag. The MERCHANT_ID placeholder needs to be replaced with your Advertiser ID.
In addition, please note that the code is tailored for a DEFAULT commission group. If you are using multiple commission groups, the parts variables will need to be dynamically populated with the commission group code(s) being used.
<?php //------------------------------------------- // START AWIN CONVERSION VALUE TRACKING CODE //------------------------------------------- $lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId(); $order = Mage::getModel('sales/order')->load($lastOrderId); $_products = $order->getAllItems(); $_totalData = $order->getData(); $_grand = $_totalData['grand_total']; $_sub = $_totalData['subtotal']; $_ship = $_totalData['shipping_amount']; $_discount = $_totalData['discount_amount']; $_voucher = $_totalData['coupon_code']; $_total = $_sub + $_discount; ?> <img src="https://www.awin1.com/sread.img?tt=ns&tv=2&merchant=MERCHANT_ID&amount=<?php echo $_total; ?>&ref=<?php echo $this->getOrderId(); ?>&parts=DEFAULT:<?php echo $_total; ?>&vc=<?php echo $_voucher; ?>&testmode=0&cr=GBP" /> <form style="display:none;" name="aw_basket_form"> <textarea wrap="physical" id="aw_basket"> <?php $productLines = array(); foreach($_products as $product => $p) { if ($p['order_id'] == $lastOrderId) { if (is_null($p['parent_item_id'])) { $productLines[$p['item_id']] = 'AW:P|MERCHANT_ID|' . $this->getOrderId() . '|' . $p->getProductId() . '|' . $p->getName() . '|' . $p->getPrice() . '|' . round($p->getQtyOrdered(), 0) . '|' . $p->getSku() . '|DEFAULT|CATEGORY' . "\r\n"; } } } foreach ($productLines as $productLine) { echo $productLine; } ?> </textarea> </form> <script type="text/javascript"> //<![CDATA[ /*** Do not change ***/ var AWIN = {}; AWIN.Tracking = {}; AWIN.Tracking.Sale = {}; /*** Set your transaction parameters ***/ AWIN.Tracking.Sale.amount = '<?php echo $_total; ?>'; AWIN.Tracking.Sale.currency = 'GBP'; AWIN.Tracking.Sale.orderRef = '<?php echo $this->getOrderId(); ?>'; AWIN.Tracking.Sale.parts = 'DEFAULT:<?php echo $_total; ?>'; AWIN.Tracking.Sale.voucher = '<?php echo $_voucher; ?>'; AWIN.Tracking.Sale.test = '0'; //]]> </script> <script src="https://www.dwin1.com/MERCHANT_ID.js" type="text/javascript" defer="defer"></script> </div>
