javascript - Facebook conversion tracking in Magento -
im trying implement new facebook conversion code in magento installation. according facebook need copy tracking code , paste between < head> , < /head> in webpage want track conversions. in magento be
app\design\frontend\xxxx\yyyy\template\checkout\success.phtml
however, cant find in file.
the code looks this, have tip of how implement it?:
<!-- facebook conversion code track facebook --> <script type="text/javascript"> var fb_param = {}; fb_param.pixel_id = 'xxxxxxxxxxxx'; fb_param.value = '0.00'; fb_param.currency = 'usd'; (function(){ var fpw = document.createelement('script'); fpw.async = true; fpw.src = '//connect.facebook.net/en_us/fp.js'; var ref = document.getelementsbytagname('script')[0]; ref.parentnode.insertbefore(fpw, ref); })(); </script> <noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/offsite_event.php?id=6015688541915&value=0&currency=usd" /></noscript>
the simplest way accomplish
in template\checkout\success.phtml
<?php $order = mage::getmodel(‘sales/order’)->loadbyincrementid($this->getorderid()); ?> <!-- facebook conversion code checkout --> <script>(function() { var _fbq = window._fbq || (window._fbq = []); if (!_fbq.loaded) { var fbds = document.createelement('script'); fbds.async = true; fbds.src = '//connect.facebook.net/en_us/fbds.js'; var s = document.getelementsbytagname('script')[0]; s.parentnode.insertbefore(fbds, s); _fbq.loaded = true; } })(); window._fbq = window._fbq || []; window._fbq.push(['track', 'xxxxxxxxxx', {'value':'<?php echo $order->getbasegrandtotal() ?>','currency':'sgd'}]); </script> <noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?ev=xxxxxxxxxxxxx&cd[value]=0.01&cd[currency]=sgd&noscript=1" /></noscript>
Comments
Post a Comment