Magento – How to Setup Facebook Ads Dynamic Variable Conversion Value

conversionfacebook

I'm using Magento Community for my online store, and I am in the process of setting up my Facebook Website Conversion ads. I have already created and verified the conversion pixels, however, the conversion value by default is 0.01. Hence I do not know my true conversion value. What I am trying to do is to set up a dynamic variable for this conversion value.

May I know what am I supposed to replace the 0.01 with?

So far I have tried finding an answer on via Google search but to no avail. This link is probably the closest (although not meant to address Facebook/Magento issues): http://printready.co/dev-and-design/setting-up-dynamic-google-conversion-values/
Basically it replaces the 0.01 with $totalValue

Just wondering what is the term in Magento that I should be replacing 0.01 with?

P.S. My code below (edited a bit for privacy issues)

<!-- 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':'0.01','currency':'SGD'}]);
</script>
<noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?ev=XXXXXXXXXXXXX&amp;cd[value]=0.01&amp;cd[currency]=SGD&amp;noscript=1" /></noscript>

Thank you very much guys!

Best Answer

Assuming that you added the above js code to success.phtml then

$order = Mage::getModel(‘sales/order’)->loadByIncrementId($this->getOrderId());


...
window._fbq.push(['track', 'XXXXXXXXXX', {'value':'<?php echo $order->getBaseGrandTotal() ?>','currency':'SGD'}]);
...

See How to Add Facebook Conversion Tracking to Magento

A better way to accomplish this would be to create a new module that is duplicate of GoogleAnalytics and make the necessary changes. Take a look at my github Magento Facebook Remarketing and Conversion Tracking

Related Topic