Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

ShareASales tracking ShareASale's tracking for Magento involves two 'tags‘tags,' which are snippets of code installed in the success.phtml template file and in the Design configuration of Magentos Magento’s admin. The first tag is for tracking conversions (i.e. sales) and the second for assisting with Affiliate click attribution accuracy in certain browsers. Installation of both should be simply copy and paste of the code included herein.

...

Make a backup of the success.phtml file.

*Note: This is an important step since you are editing core Magento files.

...

Code Block
<p><strong><?php echo $this->__('Thank you for your purchase!') ?></strong></p>
Info

...

Replace XXXXX in the script below (Line 3) with your ShareASale Merchant ID.

Info

Replace the !!!!!! in the script below (Line 37) with your Master Tag ID.

For merchants in the Setup Wizard, you can find this within Step 4 (Tracking Code Installation).

For live merchants, you can find this by navigating to MY ACCOUNT > ACCOUNT DETAILS
Account Details: https://account.shareasale.com/m-account.cfm

If you cannot locate your Master Tag ID, or would like to verify that you have one, please submit a ticket to our ShareASale support staff.

Code Block
<!-- begin ShareASale.com affiliate tracking -->
<?php
$merchantid = 'XXXXX';
$orderId = $this->getOrderId();
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
$total = $order->getGrandTotal(); //not used
$subtotal = $order->getSubtotal();
$discount = $order->getDiscountAmount();
$affiliateTotal = ($subtotal + $discount);
$ordered_items = $order->getAllVisibleItems();
$skulist = ''; //setup empty skulist param
$pricelist = ''; //setup empty pricelist param
$quantitylist = ''; //setup empty quantitylist param
$last_index = array_search(end($ordered_items), $ordered_items, true);
foreach($ordered_items as $index => $item){
$delimiter = $index === $last_index ? '' : ',';
$skulist .= $item->getSku() . $delimiter;
$quantitylist .= ceil($item->getQtyOrdered()) . $delimiter;
//append correct item base price, before any kind of cart or product discount
$pricelist .= ($item->getProduct()->getFinalPrice() - ($item->getDiscountAmount() / $item->getQtyOrdered())) . $delimiter;
}
//Magento has only one customer coupon code allowed, so no comma-separated list to make...
$couponcodes = $order->getCouponCode();
$newcustomer = ''; //setup newcustomer param
$customer = $order->getCustomerId();
if($customer){
$_orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id', $customer);
$_orderCnt = $_orders->count(); //orders count
//if customer has more than an order, they're not new. Some developers will use another method, like matching an email address or credit card number.
$newcustomer = ($_orderCnt > 1 ? 0 : 1);
}
//setup currency code
$currency = $order->getOrderCurrencyCode();
//render pixel below
?>
<img id='_SHRSL_img_1' src='https://shareasale.com/sale.cfm?tracking=<?php echo $orderId ?>&amp;amount=<?php echo $affiliateTotal ?>&amp;transtype=sale&amp;merchantID=<?php echo $merchantid ?>&amp;couponcode=<?php echo $couponcodes ?>&amp;skulist=<?php echo $skulist ?>&amp;quantitylist=<?php echo $quantitylist ?>&amp;pricelist=<?php echo $pricelist ?>&amp;newcustomer=<?php echo $newcustomer ?>&amp;currency=<?php echo $currency ?>&amp;v=1.9' width='1' height='1'>
<script src='https://www.dwin1.com/19038!!!!!.js' type='text/javascript' defer='defer'></script>
<!-- end ShareASale.com affiliate tracking -->

Copy and paste the modified script (with the correct Merchant ID and Master Tag ID) into the success.phtml file.

...

Please save and re-upload the success.phtml file to your server.

Note: Make sure you entered the correct Merchant ID! Your ID is displayed in the top left corner of your ShareASale account while logged in. This example had 44911 as the Merchant ID. 

Master Tag Installation

Open your Magento stores store's admin and click the 'System' menu in the top navigation.

...

Code Block
<script src='https://www.dwin1.com/19038!!!!!.js' type='text/javascript' defer='defer'></script>
Info

Replace the !!!!!! in the script above with your Master Tag ID.

For merchants in the Setup Wizard, you can find this within Step 4 (Tracking Code Installation).

For live merchants, you can find this by navigating to MY ACCOUNT > ACCOUNT DETAILS
Account Details: https://account.shareasale.com/m-account.cfm

If you cannot locate your Master Tag ID, or would like to verify that you have one, please submit a ticket to our ShareASale support staff.

Make sure you click Save Config button in the top right corner of the page.

...

If you were emailed a link to this document, a test link may have been provided to you. If it wasn’t, you can obtain one from your account by clicking here.

NOTE: If you do not click the test link your order will not track.

The test link should direct you to your own store. Once there, please purchase any item in your store. Sometimes Merchants will have a test item worth $1.00 sale price, but above $0.00 minimum.

...