Last active
August 29, 2015 14:07
-
-
Save shinesoftware/945650f49162920d66d2 to your computer and use it in GitHub Desktop.
This code helps you to track on a Magento Store visitors and the conversions using the Perfect Audience service.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This code should be inserted to the bottom of this file: /app/design/frontend/default/default/template/page/html/footer.phtml | |
Make sure to update your perfect audience tracking info (line 34). | |
Tested with Magento 1.9.0.1 | |
Thanks to Sam327 | |
*/ | |
<!-- Start of Perfect Audience Script --> | |
<script type="text/javascript"> | |
(function() { | |
window._pa = window._pa || {}; | |
if(document.location.href.indexOf('checkout/onepage/success') != -1) { | |
<?php | |
$_tmp_amount = 0.00; | |
$product_id = ""; | |
$lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); | |
if($lastOrderId) { | |
$_tmp_amount = Mage::getModel('sales/order')->loadByIncrementId($lastOrderId)->getBaseGrandTotal(); | |
} | |
if(Mage::registry('current_product')){ | |
$product_id = Mage::registry('current_product')->getSku(); | |
} | |
?> | |
_pa.orderId = "<?php echo $lastOrderId; ?>"; | |
_pa.revenue = "<?php echo $_tmp_amount; ?>"; | |
} | |
_pa.productId = "<?php echo $product_id; ?>"; | |
var pa = document.createElement('script'); pa.type = 'text/javascript'; pa.async = true; | |
pa.src = ('https:' == document.location.protocol ? 'https:' : 'http:') + "//tag.perfectaudience.com/serve/542e77d51230da945700000d.js"; | |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(pa, s); | |
})(); | |
</script> | |
<!-- End of Perfect Audience Script --> |
anthonycreek is correct. You need to disable caching in this specific block, else it wont work.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
footer.phtml is cached (if you have caching enabled) so you can't put the code in there. I ended up creating a block containing the PA code and calling it via the local.xml file and disabling the cache on just that block.