Integrating Magento

From Wiki

Jump to: navigation, search

Français . Italiano . Nederlands . Polski . Português (Brasil) . Svenska

Introduction

Adobe Commerce (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. Adobe Commerce (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, Adobe Commerce (Magento) offers companies the ultimate eCommerce solution

How to: Setup Awin tracking with Adobe Commerce (Magento)

The Awin 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 Awin tracking code.

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&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;ch=aw&amp;testmode=0&amp;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.channel = 'aw';
        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>


See also:
Magento V2: https://marketplace.magento.com/awin-module-advertisertracking.html
Magento V1: https://marketplace.magento.com/awin-awin.html

Privacy

Due to new European legislation regarding how websites store information about you, AWIN is updating its privacy policy. You can see the new version of our policy here. If you would like to see the information we capture on this website, please click here for further details. In order to accept cookies on this site please click the 'I ACCEPT' button