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

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?

Shopify Staff (Retired)
Shopify Staff (Retired)
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. 


12 0 1

This did the trick for me. Thanks for posting!

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?

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 = '//';
    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'}]);
<noscript><img height="1" width="1" alt="" style="display:none" src=";cd[value]=0&amp;cd[currency]=USD&amp;noscript=1"; /></noscript>
  {% endif %}


New Member
2 0 0

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

New Member
1 0 0

Hi Areez,

2 follow up questions:

1) What's the difference between adding the script in the 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: and this is the URL associated:

Can you comment on both? 


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?

New Member
4 0 0


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? 


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...