How to Fix a Double Counting Facebook Pixel in Shopify

Note: if you prefer to watch instead of reading, you can watch a video about how to fix a double counting Facebook pixel in Shopify on my YouTube channel. Or keep reading!

Note: if you prefer to watch instead of reading, you can watch a video about how to fix a double counting Facebook pixel in Shopify on my YouTube channel. Or keep reading below:

Not too long ago I was asked by an ad agency to take a look at one of their client’s Facebook ad accounts. They were having trouble with a declining return on ad spend (ROAS).

So I jumped into the account and was immediately surprised to see some exceptional revenue numbers compared to the ad spend.

We’re talking 10x returns on cold prospecting with an average order value of $300. My first thought was “the last thing they should be worried about is a slightly declining ROAS with these numbers…they should be throwing every dollar they have into scaling up the ad spend.”

But I quickly became suspicious of the numbers I was seeing. I requested access to the Google Analytics data and immediately confirmed my suspicions: the Facebook pixel was taking credit for nearly 100% of all sales.

That should never happen unless 100% of your traffic is coming from paid Facebook ads. Very unlikely. And in this case, Facebook ads only accounted for about 1/4 of the total traffic.

How to Tell if the Facebook Pixel is Double Counting

At this point I was sure there was a problem, but I needed to figure out exactly what the problem was before getting back to the agency, so I went straight to the Facebook pixel interface.

One quick way to check your Facebook pixel data is to compare the various events to your data in Google Analytics. They won’t match perfectly, but they should be pretty close. Just make sure you’re comparing the same date ranges. The Facebook pixel unfortunately has a limited date range for looking back but you can at least compare recent data.

When I checked this account, here’s what I saw:

Notice anything odd about those highlighted numbers? I’ll put it to you this way, have you ever heard of a situation where more people complete a purchase than add to cart or initiate checkout? Of course not, because it’s literally impossible. The only way to complete a purchase is by first adding something to the cart and then initiating the checkout. 

You’ll always have fewer people purchasing than adding to cart because not everyone buys.

In this case, the pixel was showing there were 1,500 purchases compared to 1,100 add to cart events and 849 initiate checkout events. If this pixel were correct, I would have seen add to cart first, initiate checkout next, and purchase last, with declining numbers at each step.

Here again, I’ve verified the pixel is not working properly and that the problem is at the purchase event so I clicked the “View Details” link under Purchase.

Here’s what I saw. Notice the timestamps of each purchase:

Almost every purchase had an identical timestamp for the exact same value. One had three timestamps and a couple of them only had one. At this point I knew exactly what the problem was: the facebook pixel was double counting or even triple counting every purchase.

[ As an aside, you might be wondering why it would single count sometimes, double count most of the time, and triple count on occasion. The reason is because some users had java disabled, which would block one of the pixels from firing. That would account for the single purchases. And other users might refresh the confirmation page. That would account for the triple purchases. ]

How to Fix a Double Counting Facebook Pixel in Shopify

Once I saw the problem and figured out this website was hosted on Shopify, I knew immediately what the problem was. They had installed the pixel twice. Shopify has a native integration with the Facebook pixel that allows you to simply input your pixel ID and Shopify will take care of the rest.

This is the method most e-commerce sites should use because it’s a seamless integration that works really well. Check your store to make sure you have that enabled before following the next steps. You can get there under Online Store >> Preferences.

This client had the correct Facebook pixel ID (which I expected to be the case) so I knew they also either hard coded the pixel into the theme files or they added it into the Additional Scripts section of Shopify. The second option was more likely so I checked there first.

You can access the Additional Scripts under Settings then Checkout:

The window is kind of small by default but in most browsers you can grab the bottom right corner of the text box to expand it. That’s what I’ve done in the image below. Sure enough, look what I found in the additional scripts section:

Since the pixel was loaded here as well as the native Shopify Facebook pixel setting, the pixel was firing twice almost every time the confirmation page loaded. That accounted for the exceptionally high ROAS and Facebook attributing almost 100% of the site’s sales to its ads.

Notice also that this pixel has the purchase amount hard-coded as $299. That is a huge mistake unless all of your products are priced exactly the same! That portion of the pixel code should have read: {value: ‘{{ subtotal_price | money_without_currency }}‘, currency: ‘USD’});.

In other words, 299.00 should be replaced with {{ subtotal_price | money_without_currency }}. That shortcode can be used for any conversion pixel, not just Facebook.

The solution to the double counting? Simply remove the Facebook pixel from the Additional Scripts section of the checkout settings and leave the Facebook pixel ID in the Online Store >> Preferences section of Shopify. That will ensure the native Shopify pixel integration is what drives the Facebook pixel data, which is what I recommend.

To reiterate: I highly recommend using Shopify’s native Facebook pixel setting and NOT hard-coding the pixel into the theme or as an additional script in the Checkout settings.

Another Place to Check

As I said before, it’s also possible the site admin had hard-coded the Facebook pixel on the cart.liquid page or elsewhere in the theme files. To check, navigate to Online Store >> Edit Code as shown below:

Hard coding pixels into the Shopify files is usually a bad idea so avoid it if at all possible. But if it’s been hard-coded, you might have to check multiple dot liquid files to find it. Just open each one individually and use a CTRL+F or CMND+F to search for your pixel ID.

If you find it, make sure you delete the entire pixel and only the pixel. It would be smart to do a test purchase to make sure nothing is broken after you save the change. Be careful when modifying the liquid files. It’s easy to break something if you don’t know what you’re doing.

Checking the Event Setup Tool

Facebook is always trying to make things easier for the average advertiser. But often making it easier creates bigger problems that most people don’t know how to address. The Event Setup Tool is one such feature.

Essentially this tool helps you attribute actions on your site to a pixel event without coding the pixel into your site. You simply click on what your customers would click on and label it as the appropriate event. Cool, right?

Except a lot of advertisers do this in addition to loading the Facebook pixel ID into the native Shopify settings. Here’s where you would check for this problem in the Pixel area of Business Manager:

After clicking on “Manage” next to an event, you’ll see something like this if you’ve setup an event using the standard pixel AND using the Events Setup Tool:

Notice how in the above case, Facebook is setup to log an Add to Cart event using the standard event code as well as two scenarios using the Event Setup Tool. That translates into double and triple counting. This same problem can occur on the Purchase event or any others.

You probably don’t need both enabled unless for some reason your site isn’t logging a particular action with the standard event code. In that case, the Events Setup Tool can act like a supplement. 

To solve this problem, hit the trash can next to each trigger under the Event Setup Tool. That’s assuming you are logging data using the Event Code as well, of course. 

Be Sure to Check Your Apps

Shopify has tons and tons of apps that can make your store better. But some of them prompt you to re-enter your Facebook pixel which often leads to double counting all pixel events, including purchases. So be sure to check the apps you have installed to see if that’s the source of the extra pixel code.

Bonus Tip: Preventing Checkout Page Refresh From Logging Multiple Conversions

I always recommend using the native integrations for the Facebook pixel and Google Analytics within Shopify, but that means all the other pixel has to be put in the Additional Scripts section in order to track sales from various platforms (think Bing, Google Ads, Pinterest, Twitter, etc).

However, if a customer refreshes the confirmation page or bookmarks it and views it again later (happens more than you might think) then those pixels will fire every time and log additional sales that never occurred.

That’s what drove the triple counting in the example data above.

Luckily there is an easy workaround to this problem. In the Additional Scripts text box, use this code format:

{% if first_time_accessed %}
<!– Conversion scripts you want to run only once –>

Put all your conversion pixels that you only want to fire the first time here

{% else %}
<!– Scripts you want to run on every visit –>

Put all the other pixels/tags you want to run on every visit here

{% endif %}

Generally, you only want the pixels to fire once but if you want checkout page refreshes to be logged as a pageview then you could also put that code in the second portion so that it fires on every visit.

I highly recommend setting your conversion pixels to only fire once, however. It’s no use logging extra sales that didn’t occur. All that does is give you bad data which leads to bad ad decisions.

To reiterate: I highly recommend using Shopify’s native Facebook pixel setting and NOT hard-coding the pixel into the theme or as an additional script in the Checkout settings. But if you do put it here, make sure it only fires once. You can put other pixels here, however, like for Google Ads, Bing Ads, Pinterest, etc. 

What if You're Not on Shopify?

If you’re using a different e-commerce platform like Magento, WooCommerce, BigCommerce, etc, and you’re getting double or triple counted conversions, the solution is probably similar to what you’re seeing here.

In other words, you’ve somehow installed the pixel twice through a native integration and possibly again under a custom scripts section. The solution is just as easy: remove the one you don’t need. Most likely the native integration will be the one you should keep.

How Did the Client React?

Believe it or not, the agency was not happy with what I showed them. The employee in charge of the ad account tried pretty hard to defend the existing setup. The bad data was making him look really good so he didn’t want to admit that he didn’t spot this and his past work wasn’t nearly as good as everyone thought.

And even his boss was reluctant to accept the obvious truth. After all, what client would be happy to hear “hey your ad results for the past several months have been overinflated by a huge percentage”. 

But in the end, there was no denying the truth and the agency told the client. The really sad part was all the past ad data was basically worthless so we had to start from scratch learning what actually was driving conversions and what wasn’t. Better late than never, though.

Moral of the story: make sure your pixel data is correct before running ads!

Need Help with Your Facebook Pixel?

I get a lot of requests for free troubleshooting of Facebook pixels, but unfortunately I don’t have the bandwidth to provide that. I do of course fix pixel issues for my DFY clients, so if you are interested in having me and my team manage your ad accounts, please book a strategy session (link at top of site). 

If you only need help with your pixel, please do not book a call with me. Your best bet is to use this blogpost or look on Upwork for a pixel expert.

Leo Ebbert

Leo Ebbert

Leo Ebbert is a 14-year internet marketing veteran who has helped dozens of E-commerce businesses dominate their space online.

40 Responses

    1. Sorry for the delayed response. The notification got stuck in my junk folder. I’m not too familiar with Woocommerce unfortunately. The problem you’re having is odd, to say the least. The only time I’ve seen something similar was a site that had a WordPress front end and a Magento back end and the pixels were only installed on one end of the site rather than both. So if the pixel doesn’t fire on every page it could not log all of them. Check to make sure your pixel is logging activity at every step of the sales funnel on your site.

      The only other possibility I can think of is if you put the tag at the bottom of the code and maybe it’s not loading before people browse to the next page.

  1. Hey Leo! Great article.

    I’m new to running Facebook ads and am getting 2 purchases/unique purchase. However, the event is not double firing but there are two separate pixels firing simultaneously. I know we create ads based on a single pixel, so how can it be 2x?


    1. If there are two separate pixels firing that means that you’ve got the pixel code loading twice but with different pixel IDs. If you view the page source and do a search for a piece of the FB code, you’ll see it in there twice. Look at the pixel ID for each one and compare it to the pixel ID of the pixel you want to use. Delete the other one and you should be good to go.

  2. Hello Leo,
    I am running Google Ads and separate Facebook Ads. I can see in the shopify order section, where the customer came from, but Facebook counts all purchases which came via Google as well.

    Have you experienced something similar? How do I prevent this count in order to measure a Facebook Ad correctly?

    1. Hi Mehdi,

      What you’re seeing isn’t all that uncommon because if users are exposed to your ads on both channels, they’ll both want credit, or at least partial credit. Google I think does a better job of taking partial credit if you use their data driven or “position based” conversion setting.

      Facebook does at least allow you to break it out by click vs view attribution, but that doesn’t tell as full a story as Google’s conversion tells.

      So bottom line is this isn’t abnormal because users are often exposed to ads on more than one channel before buying and that means both channels are going to claim at least some credit.

  3. Hi Leo!

    Hope you can help with this. On shopify and have the pixel installed through the native set up. Issue is on the purchase it’s passing the subtotal and I want the order total so including shipping. Can this be done through the native set up or should I just code it myself? THANKS!

    1. I’m not aware of a way to tweak the native setup. There might be an app that addresses it but you’ll probably have to disable the native tracking and install the code manually to track the way you want.

  4. Is there any way to list purchases registered by the pixel? In Ad Manager I tried all of the unsuccessful breakpoint combinations due to the volume of purchases.
    I also tried unsuccessful analytics. In my case Listing all purchases one by one would make it much easier to identify duplicates. Know a way to do this?

    1. Click on “view details” under the Purchases event and you’ll see transaction IDs of each purchase. You can see screenshots in the post that show how to do that.

  5. Hi Leo. Our Facebook pixel was giving us issues so we had to code some events into the .liquid pages. Our ViewContent and ATC is now working. But the InitiateCheckout is a bit tricky. It was originally not working at all in our Brooklyn theme when somebody clicked checkout in the popup cart drawer. Sometimes it was working from Instagram only but most of the time it was not working. To combat that, we added a code into the cart.liquid as:

    That seemed to fix the issue of InitiateCheckout working from the Cart page but not from cart drawer. We got a Shopify theme developer to change the link of our checkout button from the cart drawer to go directly to our Cart page where if they click checkout, it now shows up. But now when they click checkout from the Cart page, the InitiateCheckout is firing twice. Any thoughts on what can be done?

    1. Hi samad, i have the same problem with brooklyn theme and initiatecheckout (trigger doesn’t work)….how have you solved? please, help me

  6. Also, I should mention that the InitiateCheckout firing twice is happening when it comes from mobile. It fires correctly only once when it comes from Desktop. When trying to find out more info, one of them says:

    This content ID matches to one or more of your catalogs.

    The other one does not mention any Parameters.

    1. Hi Samad,

      I wish I could be more help on this problem but I’m not much of a programmer. In hindsight, computer science would have been a better major for me in college than accounting haha. But if I had your problem I would hire a developer to look at it b/c it’s too far outside my expertise. Sorry I can’t be more help.

  7. Great post Leo! My setup is correct on Shopify but having some purchases counted twice. However, it’s just the number of “purchase” and not the actual amount. So amount is absolutely right but it sometimes say 2 sales instead of 1. Would that be users refreshing the page or bookmarking it? I would assume so?

    In my case, ATC, IC and purchase seem absolutely correct but API doesn’t. However, I would assume that PayPal or Google checkout might prevent API from firing, no?

    1. Hi Lisa, in Shopify it usually comes down to the native pixel settings or the checkout settings where you can hardcode the pixel code. But recently I’ve seen cases where people have installed a Shopify app that is also firing the pixel which leads to duplicates like you’ve mentioned. So check to see if you have any apps doing that.

      The other possibility is you’re using a poorly coded or outdated theme that isn’t playing well w the pixel.

  8. Also Leo, just FYI, I just realized that a lot of events were being double counted because FB had manually also set them up via its event setup tool. If you click on “Event Manager” and then Settings, you can check ALL the events that are being fired.

  9. Hi Leo,

    Thank you so much for this amazing article. You are an absolute lifesaver!

    I am trying to code in the {% if first_time_accessed %}

    To avoid the confirmation page recording sales when the customer checks their tracking etc. I am just not sure how to enter the conversion script.

    Do I enter fbq(‘track’, ‘Purchase’, {value: ‘0.00’, currency: ‘USD’});?

    P.s I am not a coder, apologies if this is super simple 🙂

    1. Hi Zane, you only want to put the FB code there if you aren’t using the native pixel option under Shopify Settings. I would recommend using the native option which means you shouldn’t put any portion of the FB pixel code on the checkout scripts. If you decide to use the scripts page, put the entire Facebook pixel code including the event script you posted in your comment. Hope that helps!

  10. Hi Leo, thank you for this amazing article.
    My events come without content_name. So when I use FB analytics I don’t get any results. Thanks

  11. Hi Leo,

    Great article!

    Quick question about the bonus tip on how to prevent checkout page refresh from logging multiple conversions.

    *Put all your conversion pixels that you only want to fire the first time here*

    What do you mean by that? I guess it’s not just the Facebook Pixel ID I would paste in there, but what is that specific “conversion pixel” you’re talking about and where do I find it?

    And also, if I don’t want any other pixels/tags to run on every visit, I’d leave that part just blank?

    Thank you!

    1. You shouldn’t put the FB pixel on the scripts page. You should use the native Shopify settings for FB. You can put other pixels in the scripts section that will make them fire only one time. And yes, leave the section for pixels to fire multiple times blank.

  12. Hi Leo,
    I’ve been having issues with my pixel firing off purchase events on the homepage and product page, which is causing my data to be completely incorrect. My pixel was only installed on the preferences section on Shopify. I was told maybe an app was triggering these events but I couldn’t locate it. I also looked through the theme files to possibly find the pixel there, no luck. So I decided to get a new pixel but same issue. When I use Pixel Helper this is the message Im receiving (We detected event code but the pixel has not activated for this event, so no information was sent to Facebook. This could be due to an error in the code, but could also occur if the pixel fires on a dynamic event such as a button click.) The setup is manual, any advice?

    1. You might have a bad theme but other than that it’s hard to troubleshoot without seeing it.

  13. Hi Leo,

    I have a shopify website – in which I have installed this script recommended by you on Checkout but I have noticed that there are still double counting of conversions. Please refer below screenshot –

    Here is the customized script that I have been using on checkout –

    {% if first_time_accessed %}


    fbq(‘init’, ‘294416497709223’);
    fbq(‘track’, “PageView”);
    fbq(‘track’, ‘Purchase’, {
    value: ‘{{ total_price | money_without_currency }}’,
    currency: ‘{{ shop.currency }}’,
    order_id: ‘{{ order_number }}’,
    content_ids: [{% for line in order.line_items %}’shopify_{{ line.product_id }}_{{ line.variant_id }}'{% unless forloop.last == true %}, {% endunless %}{% endfor %}],
    content_type: ‘product’,
    num_items: ‘{{ item_count }}’

    {% else %}
    {% endif %}

    Could you please check once and help me out. Thanks in advance!

    1. As outlined in the article, you shouldn’t use the scripts section for the FB pixel, you should use the native Shopify settings only. If you have it in both places it will cause double counting.

      1. Thank you Leo. I have deleted the additional script from shopify settings. But still there are a few orders which are counting twice in Facebook ads manager.
        Is this due to reloading of /orders page ?
        If yes, then how to get rid of this? Please advice.

  14. So does a double firing pixel also cost you twice as much in ad spend then? I am guessing since you mentioned the ad sets had to be wiped and restarted for learning, that they were getting charged double/triple per purchase?

    1. FB doesn’t charge based on pixel fires. It charges based on impressions on their platform

  15. I’m having this issue, you mention to use the native pixel integration you have mentioned under Preferences:

    However, I am still seeing double conversions. Then you go to on to mention to use this:

    {% if first_time_accessed %}

    In the Additional Scripts section I assume? But I am using the native integration only, so how can I make sure I stop getting the double conversions with the native pixel integration?

    I assume there is some way to do it with the native integration, but I am not seeing it…

    1. No if you’re using the native integration, you don’t need to worry about the first time accessed code on the additional scripts page. That only applies if you aren’t using the native pixel setting or also if you have other pixels on the site that you want to block from double counting (like Google Ads or Bing Ads for example).

  16. Although, at the event manager the error showing is that “Event id is missing” and due to this events are not being Deduplicated. So how can I share event_id?

  17. THANK. YOU. SO. MUCH. I have read every facebook help article (which are always out of date don’t you think?) and you showing how to find the ‘manage’ event was the only article I found showing WHO my ‘intergrated partner’ was that I was seeing in testing. And so good to hear that you trust the Shopify pixel intergration as I think I just must have got too interested in the ‘event set up tool’ without realising I didn’t need it. Just one thing to say however is that one of your images is ‘missing’ but I eventually worked out what you were trying to say. THANKS AGAIN!

  18. Hi,

    I used GTM Facebook Pixel (3rd party integration) for PageViews, ViewContent, Purchase and another Custom Event deployed with one pixel ID1 and another one deployed using the HTML (Page Views) with pixel ID2, So when I am debugging using the facebook pixel helper it’s showing that for the pixel ID1 which is deployed through 3rd party integration the page views are firing multiple times error, not able to figure it out what the issue is.

Leave a Reply

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