Last active
August 29, 2015 14:03
-
-
Save tvpmb/ad6144f967f879fe9ae0 to your computer and use it in GitHub Desktop.
TVPage Magento PHP Conversion Tracking Script
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
| <!-- START TVPAGE CONVERSION SCRIPT --> | |
| <?php | |
| $order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId()); | |
| $items = $order->getAllVisibleItems(); | |
| $trackItems = Array(); | |
| foreach($items as $i) { | |
| $trackItems[] = '{ sku: "'.$i->getSku().'", price:"'.$i->getBasePrice().'", quantity:'.$i->getQtyOrdered().' }'; | |
| } | |
| $trackData = implode(",", $trackItems); | |
| ?> | |
| <script type="text/javascript"> | |
| (function() { | |
| var tvpa = document.createElement('script'); tvpa.type = 'text/javascript'; tvpa.async = true; | |
| tvpa.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://a.tvpage.com/tvpa.min.js'; | |
| var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(tvpa, s); | |
| })(); | |
| var _tvpa = _tvpa || []; | |
| _tvpa.push(['config', { | |
| tr: "XXX", // Data source ID | |
| li: "YYY" // Account ID | |
| }]); | |
| _tvpa.push(['track', 'products',[ <?php echo $trackData;?> ]]); | |
| </script> | |
| <!-- END TVPAGE CONVERSION SCRIPT --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment