How to fix Duplicate Facebook pixel ID error?

后端 未结 7 1883
暖寄归人
暖寄归人 2021-02-02 08:11

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

7条回答
  •  清歌不尽
    2021-02-02 08:32

    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}}');
      }
    

提交回复
热议问题