Skip to content

Instantly share code, notes, and snippets.

@yashodhank
Forked from chrisjhoughton/fb-conversion.liquid
Created July 30, 2016 18:25
Show Gist options
  • Save yashodhank/d7041716b4a7734cdb6589befcd2288b to your computer and use it in GitHub Desktop.
Save yashodhank/d7041716b4a7734cdb6589befcd2288b to your computer and use it in GitHub Desktop.
Facebook's conversion pixel code, ready to go for Shopify with liquid variables. Change the `youraccountid` and add this to the "additional content and scripts" section of your checkout settings.
<!-- Facebook Conversion code -->
{% assign fb_pixel_id = 'yourpixelid' %}
<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', '{{ fb_pixel_id }}', {'value': '{{ order.total_price | money_without_currency }}','currency':'{{ shop.currency}}'}]);
</script>
<noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?ev={{ fb_pixel_id }}&amp;cd[value]={{ order.total_price | money_without_currency }}&amp;cd[currency]={{ shop.currency }}&amp;noscript=1" /></noscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment