Integrating Magento

From Wiki

Jump to: navigation, search

Introduction

Magento is a feature-rich eCommerce platform built on open-source technology that provides online merchants 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 merchants 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.

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 Merchant 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(); 
 
$_products = Mage::getSingleton('sales/order')->getItemsCollection()->getData(); //Use this for Product Level Tracking...
 
$order = Mage::getSingleton('sales/order'); 
$order->load($lastOrderId);
 
$_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&amp;tv=2&amp;merchant=MERCHANT_ID&amp;amount=<?php echo $_total; ?>&amp;ref=<?php echo $this->getOrderId(); ?>&amp;parts=DEFAULT:<?php echo $_total; ?>&amp;vc=<?php echo $_voucher; ?>&amp;testmode=0&amp;cr=GBP" />
 
<form style="display:none;" name="aw_basket_form">
 <textarea wrap="physical" id="aw_basket">
<?php 
foreach($_products as $p) {
    if($p[order_id] == $lastOrderId) {
        echo 'AW:P|MERCHANT_ID|' . $this->getOrderId() . '|' . $p[product_id] . '|' . $p[name] . '|' . $p[price] . '|' . round($p[qty_ordered], 0) . '|' . $p[sku] . '|DEFAULT|CATEGORY' . "\r\n";
    }
}
?>
</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>