How do I add a Facebook conversion tracking code into the <head> of one of my pages?

Highlighted
New Member
3 0 4

I'm trying to add a Facebook conversion code into the head of my pages. How do I find the <head> to these?

4 Likes
Shopify Staff
Shopify Staff
58 0 3

Hey Allen!

You would want to add this conversion code into your template editor within the theme.liquid. Shopify's template systems uses that on every page, and that's where your <head></head> code lives. You would want to add an if statement so that the code only fires on that page. Something along the lines of

 

{% if page.title == "Title of the Conversion page" %> FACEBOOK CONVERSION CODE {% endif %} 

between the <head> </head>. Generally, putting that code right above the </head> tag would be best. 

 

0 Likes
Tourist
12 0 1

This did the trick for me. Thanks for posting!

0 Likes
New Member
1 0 1

Where do I find the title of the conversion page, assuming I wanted it to be the thank you confirmation after checkout?

1 Like
Shopify Partner
1 0 0

Hey guys, I'm still having a bit of trouble getting the facebook conversion pixel in the header of my Thank You page.

I've got the latest tracking pixel here and added the if statement you mentioned in the post above as a wrapped just about the </head> tag.

My issue is I don't know the name of the Thank You page after an order is complete to make the IF statement work.  Is it just if page.title == "Thank You" ?  

Any help here would be awesome.

  <!-- Facebook Conversion Code for Shopify -->
  {% if page.title == "Title of the Conversion page" %}
<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', '#############', {'value':'0.00','currency':'USD'}]);
</script>
<noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?ev=#############&amp;cd[value]=0&amp;cd[currency]=USD&amp;noscript=1"; /></noscript>
  {% endif %}

 

0 Likes
New Member
2 0 0

Go to Settings => Checkout, then scroll down to "Additional content & scripts" and paste your conversion code there.

0 Likes
New Member
1 0 0

Hi Areez,

2 follow up questions:

1) What's the difference between adding the script in the template.page vs. adding it to Settings > Checkout > Additional Content & Scripts. 

2) I also don't know what the name of my "Thank You page" is upon checkout. This is what it looks like: http://cl.ly/W25Y and this is the URL associated: https://checkout.shopify.com/orders/2336541/232ac7c9c1670fff1e93a3a06ec3fdfd

Can you comment on both? 

Thanks.

0 Likes
New Member
14 0 0

Gentlemen, the one problem that we have here is that the title of the confirmation / thank you page is the same as the other checkout: [Shop Name ]- Checkout

 

At least it is for ours.  This is definitely laziness on Shopify's part.  What other conditionals could we use other than the page title?

0 Likes
New Member
4 0 0

Areez,

It's been 4 months since you posted this without a follow up. Can you elaborate a little bit more on how to use this if statement? 

Thanks!

0 Likes
Tourist
14 0 1

Can we get some clarity on this? It's relevant more than ever these days and I can't find a clear answer...

0 Likes