You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I struggled for quite some time getting Pixel implemented using Gatsby. It turns out the "out of the box" FB pixel script has a check to see if fbq function already exists on the window, and if it does then to return (and do nothing):
if (f.fbq) return;
(I think) this causes a problem as the Partytown React component is already creating the fbq method, and therefore the f.fbq is true and the rest of the pixel code is not being executed. Below is my Partytown component:
I resolved it by removing that check (in the FB code), although I'm unsure if that's the best/only approach? If it is i'm happy to update the docs to cover this.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi Team,
I struggled for quite some time getting Pixel implemented using Gatsby. It turns out the "out of the box" FB pixel script has a check to see if fbq function already exists on the window, and if it does then to return (and do nothing):
if (f.fbq) return;
(I think) this causes a problem as the Partytown React component is already creating the fbq method, and therefore the f.fbq is true and the rest of the pixel code is not being executed. Below is my Partytown component:
<Partytown key="partytown" forward={['fbq']} resolveUrl={resolveURL} logCalls={true} logGetters={true} logSetters={true} logImageRequests={true} logScriptExecution={true} logSendBeaconRequests={true} logStackTraces={true} />
I resolved it by removing that check (in the FB code), although I'm unsure if that's the best/only approach? If it is i'm happy to update the docs to cover this.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions