Added facebook pixel like they showed here here Now getting an error:
fbevents.js:9 Facebook Pixel Error: Duplicate Pixel ID: some-pixel-id
Canno
This error generally means fbq('init', <pixel_id>)
is getting called more than once with the same pixel id.
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}}');
}
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.
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
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.
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!)."