Magento

Please note: We provide this information ‘as-is’ as a courtesy to our clientele, and as such, it may contain typos, become outdated, go out of style, be factually incorrect, or considered 'using cheats' if playing on hard mode. We cannot vouch for its seaworthiness; sail at your own risk, and please email us with any improvements we can make!

Overview


Magento is a very technical e-commerce system, offering both Enterprise and Community versions, as well as the new Magento 2.0 (as of the end of 2015). You should absolutely have an IT team (or hire a contractor, or if you have Enterprise edition, use Magento Support)  to help work with any customization you may need to do. We will assist to the best of our ability, but us communicating highly technical recommendations for your custom environment, to a non-technical end-user to enact the changes, is the blind leading the blind.

 

Contents

Magento 1.0
Magento 2.0
PlumRocket
 
 
 
Magento 1.0 


1. Site Wide Tracking Script - Footer

The site-wide script would be placed in the Magento admin dashboard in System > Configuration > General > Design > Footer > Miscellaneous HTML.

<script type="text/javascript"> (function() { var avm = document.createElement('script'); avm.type = 'text/javascript'; avm.async = true; avm.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.avmws.com/[SITE_ID]/'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(avm, s); })(); </script>

2. Order Confirmation Script

Then, this script would be appended to the end of /app/design/frontend/[theme]/[theme]/checkout/success.phtml

<?php

$order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$amount = $order->getSubtotal();
$orderid = $order->getIncrementId();
$items = $order->getAllItems();

echo "<script type=\"text/javascript\">";
echo "var _AvantMetrics = _AvantMetrics || [];
_AvantMetrics.push(['order',{ order_id:'{$orderid}', amount:'{$amount}', state:'', country:'' }]);";

foreach($items as $item) {
$_sku = $item->getSku();
$_itemprice = $item->getPrice();
$_itemqty = $item->getQtyOrdered();
echo "_AvantMetrics.push(['item',{ order_id:'{$orderid}', parent_sku:'{$_sku}', variant_sku:'{$_sku}', price:'{$_itemprice}', qty:'{$_itemqty}' }]); ";
}
echo "</script>"
?>
(This script was gratefully provided by SamC via StackExchange.)

 

 

Magento 2.0

 

Note: We haven't had a chance to develop a 'plug and play' script for this yet, but here's all the relevant information to help get you started.

Overview

Magento 2 is remarkably different than 1.0. It now uses Composer to manage dependencies; uses strictly validated XML modules to prevent dependency injection; has deprecated the once-omnipresent Mage::class, and rebuilt their custom Controllers.

In short, this means that adding custom code requires a lot of highly technical changes!

Please see their Developer Roadmap for proper steps on how to extend the code properly and ensure it passes unit testing, etc:

M2.0 Developer Roadmap:
http://devdocs.magento.com/guides/v2.0/extension-dev-guide/intro/developers_roadmap.html


Migration

If you are migrating from Magento 1.0 to 2.0, you will want to check their documentation, and their official Migration tool:

Magento official Migration Guide:
http://devdocs.magento.com/guides/v2.0/migration/bk-migration-guide.html

Magento Code Migration tool:
https://github.com/magento/code-migration

Walkthrough

I am not sure if Magento provides an 'easy to use GUI' to help extend and customize this, or whether it's only extensible via the very technical process below.

Overvew for site-wide tracking script:

1. Edit the default.xml to allow the reference to a new resource -- either a direct reference to JS, or to a new Magento block.
2. Either include the script reference in your footer.phtml or container.phtml directly, or, create a new Block (default_head_blocks.xml), add our site-wide tracking code to the block, and then include the block in your Container or Footer file.

Overview for Order Confirmation Script:

1. Edit the 2x XML files preventing Dependency Injection (di.xml and the checkout_onepage_success.xml).
2. Create a Block, with a publicly-scoped function which includes our Order Confirmation code. (Some customization required to pull the order and item information via $block->getOrder() function.)
3. Call that function from the success.phtml file.

Resources

Stack Overflow: Magento 2 Order Preview on Success Page:
http://stackoverflow.com/questions/34921568/magento-2-get-order-preview-on-success-page

This provides some simple steps regarding hacking the dependency injection prevention XML modules to include extended classes, extending the Success class to access the Order details, and a sample output script on the "extended' Success page. (This sample output script would basically be replaced with our script, pushing the variables to the _AvantMetrics array and then firing our callback. Hopefully, details coming soon!)

Stack Overflow: Magento 2 Adding a Block:
http://magento.stackexchange.com/questions/76392/magento-2-how-to-insert-template-block-into-page-top

This is a good example of how to add a code block to all pages on your site.

Magento DevDocs Allowed Resource Types:
http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/layout-types.html#layout-type-conf-loc 

This indicates that calling <script> tags directly is supported.

M2.0 Developer Roadmap:
http://devdocs.magento.com/guides/v2.0/extension-dev-guide/intro/developers_roadmap.html

Magento official Migration Guide:
http://devdocs.magento.com/guides/v2.0/migration/bk-migration-guide.html

Magento Code Migration tool:
https://github.com/magento/code-migration

 

 

PlumRocket

Thanks to the team at Klymit for sending this over! Here's the PlumRocket guide to installing the AvantLink integration on their managed Magento 2 installs. 

 

Page Last Edited: 2016-06-06 by Owen: Added PlumRocket and Contents links

Have more questions? Submit a request
Powered by Zendesk