Skip to content

Instantly share code, notes, and snippets.

@chrisjhoughton
Last active February 19, 2022 04:57
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chrisjhoughton/1dc91dd7bd95717e08d3 to your computer and use it in GitHub Desktop.
Save chrisjhoughton/1dc91dd7bd95717e08d3 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>
@jetlej
Copy link

jetlej commented Sep 29, 2020

I think you mean Change the 'yourpixelid' in your description :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment