Reputation: 61
im trying to implement a new Facebook conversion code in my Magento installation. According to Facebook i need to copy the tracking code and paste it between < head> and < /head> in the webpage where I want to track conversions. In Magento this would be
app\design\frontend\XXXX\YYYY\template\checkout\success.phtml
However, i cant find any in this file.
The code looks like this, do anybody have any tip of how to implement it?:
<!-- Facebook Conversion Code for 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>
Upvotes: 2
Views: 9557
Reputation: 17656
The simplest way to accomplish this
In template\checkout\success.phtml
<?php $order = Mage::getModel(‘sales/order’)->loadByIncrementId($this->getOrderId()); ?>
<!-- Facebook Conversion Code for 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>
Upvotes: 1