How to fix Duplicate Facebook pixel ID error?
Asked Answered
W

8

37

Added facebook pixel like they showed here here Now getting an error:

fbevents.js:9 Facebook Pixel Error: Duplicate Pixel ID: some-pixel-id

Cannot understand what causes this error. Even when I run the code from their example with removed pixel code from html in the console I get the same result.

Anyone knows what that means and how to solve this error ?

Walkabout answered 30/3, 2016 at 15:29 Comment(2)
I had the same issue. My change was adding Google Tag Manager and Facebook Pixel. Having both up caused this error. Removed Facebook Pixel (single) and left the one I added to Google Tag manager.Chafe
You can download the "Facebook Pixel Helper" to help to debug: marketlytics.com/analytics-faq/…Action
C
38

I found the solution on this page actually.

Its because everytime you send an event the code is initialized with the same pixel id. Actually initialization should happen only once."

This fix works. You can verify that by using the Facebook Pixel Helper as an extension in Chrome.

if(typeof fbq === 'undefined') {
    !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','https://connect.facebook.net/en_US/fbevents.js');

    fbq('init', '123123123213121');
    fbq('track', 'PageView');
    fbq('track', '{{fBPixelType}}');
  }
  else {
    fbq('track', '{{fBPixelType}}');
  }
Cyprinodont answered 20/7, 2016 at 11:1 Comment(0)
F
23

This error generally means fbq('init', <pixel_id>) is getting called more than once with the same pixel id.

Fortify answered 30/3, 2016 at 18:12 Comment(2)
Interesting how. As I was saying before, I tried running the code from the console on the page which is not containing that code (no facebook pixel on the page at all). Got the same result. I didn't duplicate anything. Facebook pixel helper says pixel loads fine, but the error keeps alerting. And yes, I'm 100% sure that there's no fbq('init', <pixel_id>) duplicate on the page. But thanks for the effort.Walkabout
Running into this issue too and there isn't much to go on.Capapie
D
4

Another answer found in the Google Forum: "You have to check whether your Facebook Pixel code is only initialised once per page (and not per event). Go to the tag where your FB Pixel code is and open the advanced settings. Tag firing options -> Once per page (not event!)."

Donia answered 16/1, 2018 at 21:42 Comment(0)
T
3

I had the same issue, and changing the facebook pixel initialization tag on GTM to "once per page" did the trick.

I know someone already answered that, but since that are more than one solution provided and the "selected" answer seems, to me, more complicated than this answer I thought i would comment here so that other people with the same problem feel confident to try this simpler approach.

Tungstate answered 14/3, 2019 at 14:21 Comment(0)
W
2

You should simply check if fbq is undefined before calling init.

if (typeof fbq === 'undefined') {
    fbq('init', 'your-pixel-ID');
}

Please note: don't wrap the full script with this if statement!

Weidner answered 19/12, 2020 at 10:22 Comment(0)
T
1

This error will only occur if you try to initialize a pixel ID more than once, so you need to check all of the JavaScript code loading on your site and find where the multiple calls to init your pixel ID are coming from.

Key area to check is to right-click on your site and click "View page source." Then check all referenced JavaScript files and any GTM containers you are referencing. I've heard of developers including the Facebook pixel code both in the <head> of the site and in a GTM container, which would cause this error.

If you're having trouble finding the two init calls, one of the easiest ways to look for specific JavaScript code on a site is to use Chrome Developer Tools. Press F12 to open the tools, press Ctrl+Shift+F to open the search panel, then type fbq or whatever you are looking for. It will go through the sources it has loaded for the site and look for that code.

Trin answered 21/4, 2018 at 22:53 Comment(1)
This really helped. There was another plugin (CTX Feed) that was configured to insert the pixel - again. Problem solved.Tincture
L
0

Before looking into hacking any code, it's worth checking the new trackSingle call:

fbq('trackSingle', 'pixel-id1', 'PageView');
fbq('trackSingle', 'pixel-id2', 'Purchase');

It allows to use in one script, multiple fbq functions with different scopes ('PageView','Purchase'), if the scope is instead the same for both pixels (for example 'PageView'), then you might just use the call like this:

fbq('init', 'pixel-id1');
fbq('init', 'pixel-id2');
fbq('track', 'PageView');
Linguist answered 11/3, 2021 at 4:47 Comment(0)
I
-1

I was having the same issue in my shopify store but I researched and find out that Trackify fb pixel app is my option. I removed all previous pixels and events that I created in past (was experimenting) and install the app it helps creating multiple events and pixels

Introject answered 27/3, 2018 at 9:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.