• Home
  • Blog Categories
    • AdWords
    • Facebook
    • Amazon
    • eCommerce
    • Lead Generation
    • Google Exams
  • Blog Archive

PPC Wins

Tips & strategies for getting the most from your PPC campaigns

New Facebook Pixel & Shopify – How to Setup Conversion Tracking

November 7, 2015 By John King 51 Comments

Edit: When I first wrote this article, it was necessary to manually implement the Facebook tracking pixels. However, since then, Shopify has made the process really simple!

You can simply take your Facebook pixel ID, and paste it into the Shopify Admin.

The section you’re looking for is currently located at Sales Channels > Online Store > Preferences. Scroll down to this section and paste your pixel ID in:

Screen Shot 2016-07-29 at 16.23.44

Shopify’s article has more information on the process, and how their implementation works!

Old Article:

Implementing Facebook’s new tracking pixel on your Shopify store is relatively straightforward, like anything, once you know how.

At a high level, it works in two parts. You have a piece of code that goes on all pages, and then you have additional code, added below it,  that will capture and pass information to the tracking pixel.

The extra information could be things like telling Facebook the customer has landed on the order confirmation page, or they landed on the cart page – and you could then pass Facebook the products that are in the cart at the moment.

Below we’re going to cover how to add the new Facebook pixel to your store, and get it tracking your sales.

If you’d like to track add to cart actions also, then after following this, take a look at my article on the subject.

First load up Power Editor, then go to Tools > Pixels:

If you haven’t visited this page before, you may get a nice splash screen introducing you to the “new” pixel.

Now you’ll want to go to Actions > View Pixel Code:

The code comes in two parts. The first is a snippet that you’ll want to use on all pages:

As Facebook suggests, this needs to go in between <head> tags. Which can be found in your theme’s theme.liquid file.

If you want a specific location, I’d suggest adding the code just before the closing </head> tag.

Next we need to add a modified version of this code to your checkout page.

You can access your Shopify’s checkout code by going to Settings > Checkout. Then scroll down to Additional content and scripts:

Here we want to take the standard code, which looks something like:

base-code

Then add a small script to the bottom:

<script>

fbq('track', 'Purchase', {

value: '{{ subtotal_price | money_without_currency }}',

currency: '{{ shop.currency }}'

});

</script>

Making the full script you’re adding to look something like this:

{% if first_time_accessed %}
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');

fbq('init', '52426583439xx89');

fbq('track', 'Purchase', {
value: '{{ subtotal_price | money_without_currency }}',
currency: '{{ shop.currency }}'
});

</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=52426583439xx89&amp;ev=PageView&amp;noscript=1"
/></noscript>
{% endif %}

You can’t use all that code exactly, because you’d need to replace where it reads FB_PIXEL_ID with your actual Facebook pixel ID. But at least you get an idea of what you’re aiming for.

The {% if first_time_accessed %} tag is useful now that the order confirmation page doubles as a page for customers to track order status. It reduces the number of falsely tracked sales. Check out Shopify’s site for more info on the first time accessed tag.

The additional script uses Shopify’s liquid tags to pull in the total value of the conversion (excluding tax and shipping) + the stores currency, and passes that to Facebook.

That’s it!

To test this is all now working, there are two things you can do.

The first is to install the Facebook Pixel Helper, a Chrome extension, that you can run on your site, and it will report back if the pixel is running.

Don’t panic if it reports back saying the pixel took too long to load. Its not ideal, but from experience the pixel does still work despite this message.

Next we’ll want to check if the pixel is tracking conversions.

If you’ve got a relatively busy store, the easiest way to do this is to wait for someone to make a purchase, then go back to the Pixel page in PowerEditor – and look under Events to see if someone made a purchase.

If sales aren’t showing up here, then there’s a good chance there’s something wrong with the code you’ve used.

To view the results of your campaigns you’ll want to select these two columns in Ads Manager:

purchase

and:

conv-value

Adding those two columns will give you the number of sales + the sales value.

So thats pretty much it.

Something that confused me initially, that might be worth pointing out, is the inter-relationship between Facebook’s pre-determined conversion types and then a feature they call Custom Conversions. The new pixel provides 9 types of conversions (see table below). Each is implemented using the new pixel, and then just customising a small bit of extra code:

However, if you want to track something outside of that scope, you can setup a custom conversion.

They work by targeting text strings in the URL:

The main thing to know is that they’re optional, and in most cases probably not needed.

If you want to setup any of the other types of conversion tracking in the table above, you’ll need a bit more information. I’ve written about tracking things like add to cart here.

There’s also the developer docs which are useful for reference.

If you’d like help getting this setup, see my work with me page.

Filed Under: eCommerce

Comments

  1. Graham Clark says

    April 20, 2017 at 5:35 pm

    When you say add the code to the bottom, do you mean under the following?

    !– DO NOT MODIFY —

    !– End Facebook Pixel Code —

    <——— Here?

    Graham

    Reply
  2. Calvin Jansen Van Vuuren says

    July 16, 2016 at 9:11 am

    facebook sucks.

    Reply
    • Gemma Two Scoops says

      May 24, 2017 at 1:37 pm

      Please join us at https://disqus.com/home/channel/iol247/, I’m being censored now at enca.

      Reply
  3. Calvin Jansen Van Vuuren says

    July 16, 2016 at 9:09 am

    please check mine….something isnt right. http://www.mouldmagics.com thank you

    Reply
  4. Calvin Jansen Van Vuuren says

    July 16, 2016 at 9:08 am

    i have a headache just trying to understand the first few lines…i have a bigger issue with the actual setup of the pixes…why cant someone just do it for me…im busy running my store…not sending my customers to the moon in a space rocket!

    Reply
  5. Vio Vio says

    July 4, 2016 at 8:20 am

    I have the following errors on shopify:
    1.
    Facebook Pixel activated 2 times.
    Event ID: PixelInitialized
    The Facebook pixel activated 2 times on this web page, which can cause errors in your event tracking.Learn more
    2. Facebook Pixel activated 2 times.
    Event ID: PageView
    The Facebook pixel activated 2 times on this web page, which can cause errors in your event tracking
    I searched on google and I found that I have add this :
    {% if first_time_access %}
    SCRIPT GOES HERE
    {% endif %}
    I did it and the errors still appear
    Also I have other 3 suggestions and I don’t know how to fix them
    1. Conversion Pixel took too long to load.
    Event ID:
    Conversion Pixel took 9127 milliseconds (9.13 seconds) to load, so some actions may not be tracked.Learn more
    2.Facebook Pixel took too long to load.
    Event ID: PixelInitialized
    Facebook Pixel took 9126 milliseconds (9.13 seconds) to load, so some actions may not be tracked.
    3.Facebook Pixel took too long to load.
    Event ID: Customer
    Facebook Pixel took 9128 milliseconds (9.13 seconds) to load, so some actions may not be tracked
    Pixel Helper suggested me to move the pixel code just before the closing tag in the HTML. I did it. These 3 suggestions still appear.
    Somebody has any solutions? Google seems not to help me.

    Reply
  6. James Pence says

    June 12, 2016 at 12:44 am

    Awesome John, how would I get the Purchase Conversion tracking event to include shipping and or taxes? 3 Different options???

    Option 1. Purchase value only
    fbq(‘track’, ‘Purchase’, {value: ‘{{ subtotal_price | money_without_currency }}’, currency: ‘{{ shop.currency }}’});

    Option 2. Purchase value and shipping only

    Option 3. Purchase value plus shipping and taxes

    Thank you!

    Regards,
    James

    Reply
    • Soummyadip Singha Roy says

      February 13, 2017 at 10:14 am

      fbq(‘track’, ‘Purchase’, {value: ‘{{order_total_paid}}’, currency: ‘{{order_currency_iso_code}}’});

      Hi friend Im not sure … but you can taste this one for tracking purchase and shipping revenue

      Reply
  7. Tanja Quinn says

    May 17, 2016 at 5:46 pm

    Hi John,

    Just to confirm, does this track that an order was placed or the revenue of the order or both?

    Reply
    • John King says

      May 17, 2016 at 8:33 pm

      Hi Tanja – this would work for both of those scenarios.

      Reply
  8. Yudansha Fightwear says

    April 19, 2016 at 3:02 pm

    Is the track PageView script not needed for the checkout code?

    Reply
    • John King says

      May 17, 2016 at 8:33 pm

      Correct, it doesn’t hurt to be there, but isn’t needed.

      Reply
  9. Dan says

    April 11, 2016 at 12:43 pm

    Great blog, made it super easy to get set up properly

    Reply
  10. Casey says

    April 1, 2016 at 4:01 am

    Great article! I did everything successfully but for some reason cannot find the areas for the step:
    “To view the results of your campaigns you’ll want to select these two columns in Ads Manager:” I cannot find those columns. I am super new at this!

    Reply
  11. Balaji says

    March 22, 2016 at 6:06 pm

    Hi John- I am trying to implement an affiliate pixel to track sales coming thru the network. The pixel seems to track orders (both order id and order value) when the order is pre-paid using the payment gateway. But when it comes to manual payments only the order id is tracked and the order value comes as 0. Is there anything you would suggest to fix this? Here’s the pixel:

    Reply
  12. DaveHime says

    January 23, 2016 at 8:12 pm

    John, thanks. This is exactly what I needed exactly when I needed it. Cheers!

    Reply
    • John King says

      February 9, 2016 at 10:41 pm

      Thanks for the messge Dave, glad it helped!

      Reply
  13. voltagenewmedia says

    January 23, 2016 at 1:11 am

    John, sorry if its just me, but adding this code, will track all facebook pixels such as Pageview, ViewContent, AddToCart, InitiateCheckout, Purchase. Or do I have to add specific pixels to each of these page templates?

    I was thinking:

    Pageview – Views the website
    ViewContent – Views a product
    AddToCart – Adds item to cart
    InitiateCheckout – Proceeds to checkout
    Purchase – Completes purchase

    Reply
    • No Sir says

      February 26, 2016 at 7:35 am

      I don’t think so, the text at the top of that page says its a module to add shipping rates.

      Reply
      • voltagenewmedia says

        February 29, 2016 at 11:34 pm

        Ive been adding add to cart, on my cart page, as well as search on my search page, its been working great.

        Reply
        • Talking Monkey says

          March 7, 2016 at 5:10 pm

          Where exactly are you guys leaving add to cart code on cart liquid ?

          Also should we see a pixel firing on the page where customers are putting in their shipping info ? I’m not getting anything firing on there.

          Reply
          • Todd Ensworth says

            March 18, 2016 at 11:27 pm

            This link should help clarify how to track add to cart/searches etc. You add an additional pixel to the theme.liquid file as well as this pixel installed on the thank you page. I created a custom pixel for the theme.liquid with if statements that only fire specific events on those particular pages.

            https://github.com/tensworth/Shopify-Facebook-Pixel

            You cannot get any firing on the shipping info page since the entire checkout is hosted on the shopify.com domain and not yours. You can sort of track adds to the cart by tracking whether they end up on the cart page. This is not necessarily accurate but it is better than nothing. Enhanced Ecommerce analytics through Google Analytics is a far better option if you want to see more accurate checkout funnel data.

  14. Rafi Rosenberg says

    January 15, 2016 at 8:22 pm

    Since the pixel on the “thank you page” which is the same page a customer will use to “track” their delivery … it seems to me the the pixel is firing multiple times for one purchase … do you find the same issue?

    Reply
    • John King says

      January 16, 2016 at 12:22 am

      Hi Rafi. Thanks for your message. Actually that’s the first time I’ve heard of people using the ‘thank you’ page to track their order. Is that in combination with a Shopify app? I thought that page stayed static and just displayed the order confirmation! Sounds like I’m missing something.

      That being said, I’ve an idea that could help.

      Shopify have a snippet of code to only run code on a customers first visit to the ‘thank you’ page:
      https://docs.shopify.com/manual/configuration/store-customization/page-specific/checkout-page/thankyou-page/first-visit-only

      I’m not sure how well it works in practice, but could be worth a try.
      I’m guessing if one visits the page on a different device, the script will run again, because no cookie is present.

      Reply
      • Rafi Rosenberg says

        January 17, 2016 at 9:25 pm

        https://docs.shopify.com/manual/settings/shipping/order-status

        yes i think your solution should work .. thanks!

        Reply
      • Misha says

        February 19, 2016 at 5:57 pm

        Great article, John. This is an important point because Shopify uses the thank you page as the order status page, so each time a customer loads the thank you page, the “purchase” event will fire, which will skew your tracking. This is the article that explains how to add code to only execute once per session. I have tested it and it’s working properly on my site.

        https://docs.shopify.com/themes/customization/order-status/first-time-accessed

        Reply
        • Dan says

          April 11, 2016 at 12:54 pm

          John has included

          {% if first_time_accessed %}

          in his code above

          Reply
  15. Anna Van Tuinen says

    December 18, 2015 at 12:52 am

    Hi John, thanks for the great tutorial. I’ve been struggling for days to get this set up. FB currently reports all pages views as “Purchases.” just one clarification– You mentioned in step 1 that the FB pixel comes in 2 parts- and to just put the first part on all pages of the site. Is it just the first paragraph…. ”

    !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
    n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
    n.push=n;n.loaded=!0;n.version=’2.0′;n.queue=[];t=b.createElement(e);t.async=!0;
    t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
    document,’script’,’//connect.facebook.net/en_US/fbevents.js’);”

    Or also the following :

    fbq(‘init’, ‘ACCT NO’);
    fbq(‘track’, “PageView”);

    Thank you for that clarification.

    Reply
    • John King says

      December 20, 2015 at 5:51 am

      Hi Anna!

      Purchases get tracked by ‘Purchase’ event code – which should only be added to the checkout page.

      The code you shared above, which includes the PageView event code, that can go on all your pages.

      Reply
      • Anna Van Tuinen says

        December 20, 2015 at 6:35 pm

        Hi John, thanks for the reply & great information! I but the base code on all pages thru GTM, and put the base code + Purchase event code on my Shopify “Thank you” page. (We’re not allowed to add code to the Checkout Page.

        Here is the code I put on the Thank You Page. Any suggestions you have will be most appreciated!!

        !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
        n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
        n.push=n;n.loaded=!0;n.version=’2.0′;n.queue=[];t=b.createElement(e);t.async=!0;
        t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
        document,’script’,’//connect.facebook.net/en_US/fbevents.js’);
        fbq(‘init’, ‘ACCT NO’);
        fbq(‘track’, “PageView”);

        fbq(‘track’, ‘Purchase’, {
        value: ‘{{ subtotal_price | money_without_currency }}’,
        currency: ‘{{ shop.currency }}’
        });

        (——I’ve also tried putting the fbq(‘track’, ‘Purchase’, directly after fbq(‘track’, “PageView”), and that doesn’t work either

        Reply
  16. Luke Moulton says

    December 7, 2015 at 11:43 pm

    Many thanks for this John. Been looking for something like this for a while now. Cheers.

    Reply
    • John King says

      December 20, 2015 at 5:49 am

      Hi Luke, thanks for the feedback! Super glad it helped :)

      Reply
  17. Richard Buckton says

    December 6, 2015 at 12:48 pm

    Hi John, great post, all stuff I’ve done several times now but I wish I’d had this the first time. I came to the post looking for more info on passing through variables other than the price and currency – they work fine. What I want to get is the product ID or title, which I can hopefully then see in the reports under Breakdown>Product ID.

    I’ve tried this in the purchase pixel with both product.id and title;

    fbq(‘track’, ‘Purchase’, {
    content_name: ‘{{ product.title }}’,
    content_ids: ‘{{ product.title }}’,
    value: ‘{{ total_price | money_without_currency }}’,
    currency: ‘GBP’
    });

    In the hope that one of those product.title variables will be picked up. Have also tried in the Add-to-Cart pixel this;

    fbq(‘track’, ‘AddToCart’, {
    value: ‘{{ product.title }}’,
    currency: ‘GBP’

    To try and trick it into pulling in the product name in the price slot but that doesn’t work (not surprising).

    I must be asking for the wrong Shopify variable or putting it in the wrong Facebook slot – or both. Any ideas? I also wonder where you can see all the different parameters in FB reporting, for example the purchase event has the following parameters available aside from price;

    content_name, content_type, content_ids, num_items

    But where can you see those in the reports?

    Reply
    • Laura says

      February 9, 2016 at 1:03 am

      Thanks John, very helpful.
      Richard, how did you go with the product title code included. Did FB pick it up?

      Reply
      • Richard Buckton says

        February 9, 2016 at 12:37 pm

        I realised that the breakdown by product ID only applies to dynamic carousel ads where you use a product feed and there’s nowhere else in the reporting where it would appear. I’ve got the sale value coming through on the purchase event but strangely not the add-to-cart. What I’d really like is order number as then I could link FB sales to sales in Shopify but when I tried to pass that through as the price it didn’t work.

        Reply
  18. Elaine says

    November 27, 2015 at 9:01 am

    Hi John, thank you for posting this! Just have a quick question here. So I need to post the codes on the html before and also the Additional content and scripts page?

    Reply
    • John King says

      November 27, 2015 at 10:10 am

      Hi Elaine. For tracking sales, the above code only needs to go in the ‘additional content and scripts’ box on your checkout page. If you add it to your template, you could end up recording sales which aren’t actually sales.

      For tracking other actions, you’d want to adjust the above code to meet ones needs, and then add it to various parts of your theme template. But of course the details of that aren’t covered above.

      Reply
      • Elaine says

        November 27, 2015 at 11:14 am

        Hi John, thank you for your prompt reply! Thanks for helping!

        Reply
        • John King says

          November 27, 2015 at 12:16 pm

          No problem, hope that makes sense. When I say ‘other actions’ above, that’s things like ‘adds to cart’ etc.

          Reply
          • Elaine says

            December 8, 2015 at 8:28 am

            Hi John, I have sent you an email sometime ago. I still couldn’t get the conversion value. Can I email you again?

      • Andrei Suciu says

        March 8, 2016 at 5:07 pm

        Hi John,

        So should we place the standard code in theme.liquid or not? As far as I can see, if i have the standard code on ‘additional content and scripts’ box, the facebook pixel helper sees my code on all pages. Now that I have inserted the standard code in theme.liquid and also in ‘additional content and scripts’ (along the purchase tracking script) , the facebook pixel helper says : facebook pixel activated 2 times. So basically my question is: Should we have the standard script on theme.liquid and the aditional purchase tracking script added in ‘additional content and scripts’ ? Or maybe both of them only in ‘additional content and scripts’ without the theme.liquid insert.

        Hope my question makes sense.

        Thank you!

        Reply
        • John King says

          March 17, 2016 at 7:26 pm

          Hi Andrei,

          Generally speaking, you want just the ‘Purchase’ code in the ‘additional content and scripts’ page. And just the PageView code in theme.liquid.

          Reply
        • Todd Ensworth says

          March 18, 2016 at 11:34 pm

          I have been working through this exact issue lately and I added a github commit to share what I ended up with. Here is a link:

          https://github.com/tensworth/Shopify-Facebook-Pixel

          Yes, you want to add the standard pixel to the theme.liquid as well as a purchase even tracker to the thank you page. I added additional events to the pixel that goes in the theme.liquid that will also track searches, contact form submissions and add to cart.

          I hope this helps.

          Reply
  19. Meghan Hickey says

    November 16, 2015 at 7:59 pm

    Hi John, does the new pixel information (how many times it’s fired) show up in the same place as the old one was showing or does it track somewhere different?

    Reply
    • John King says

      March 17, 2016 at 7:27 pm

      Hi Meghan, sorry just saw this, hopefully you’ve figured it out now.

      Reply
  20. Younes says

    November 14, 2015 at 7:06 am

    Hello John,
    Thank you for the article, very useful.
    For the chrome extension to verify the pixel, I installed it and went to my store but it didn’t find the pixel in my site. Maybe I should wait for a certain time ?

    Reply
    • John King says

      March 17, 2016 at 7:27 pm

      Hi Younes, sorry just saw this, it should be instant.

      Reply
  21. tyfisk says

    November 10, 2015 at 10:16 pm

    John thanks so much for posting this! Helped us get this setup on our site http://www.liquidcourageflasks.com. Cheers!

    Reply
    • John King says

      December 20, 2015 at 5:49 am

      Thanks! I’m glad to hear.

      Reply
  22. Mike Edwards says

    November 10, 2015 at 9:07 pm

    Update: I did “website: all” as the option in my customized column and it produced a dollar amount, which is DEFINITELY helpful. However, what do I need to do if I want to track the # of conversions on an ad, not dollar amount? Thanks.

    Reply
  23. Mike Edwards says

    November 10, 2015 at 8:58 pm

    Hey John – I have followed your directions exactly and when I did the “pixel helper” app stopped giving me errors and showin the pixel firing. However, when I run FB ads reports and customize a column to include “checkouts” FB is still just giving me a dash “—” and no results, even though some sales are happening? Any clue what I can do to remedy that?

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Popular Posts

First Time Here?

Hey and welcome to the site.

PPC Wins is a site dedicated to sharing with you useful tips and advice for getting the most out of PPC campaigns.

If there is a topic you would like to see covered please get in contact.

Categories

  • AdWords
  • Amazon
  • eCommerce
  • Facebook
  • Google Analytics
  • Google Exams
  • Lead Generation
  • Uncategorized
google-adwords-certified-partner2
BingAds_Accredited_Badge (1)

Copyright © 2022 ppcwins.com