react-facebook-pixel icon indicating copy to clipboard operation
react-facebook-pixel copied to clipboard

PageView with event ID

Open octocat512 opened this issue 3 years ago • 4 comments

PageView event with Event ID for deduplication.

Hi, We're using this package and it's really good. The only problem is related to deduplication. We want to add eventID into PageView event.

In order to add eventID, I used this code. ReactPixel.fbq('track', 'PageView', {}, { eventID });. I put this code after initialization of ReactPixel package. ReactPixel.init(PIXEL_ID);

When first page is loaded, since the above code is executed, the eventID is attaching to event info of PageView Event. But after first page, for other pages, no eventID is attaching to event Info. I added the above code for every pages ( ComponentDidMount ), but it seems that PageView event request is called automatically when page is loaded. Is there any way to add eventID into PageView Event?

octocat512 avatar May 21 '21 12:05 octocat512

Currently you cannot achieve this using the package.

In order to achieve deduplication you have to:

  • Install Pixel using the JS method here https://developers.facebook.com/docs/facebook-pixel/get-started/
  • Inside the script, remove the default fbq('track', 'PageView')

If you still find PageView events are logging automatically:

  • You can set disablePushState to true to stop sending PageView events on history state changes as stated https://developers.facebook.com/ads/blog/post/2017/05/29/tagging-a-single-page-application-facebook-pixel/: fbq.disablePushState = true before each fbq.init
  • Now you can use fbq('track', 'PageView', {}, { eventID })

If you faced a problem that no PageView events are being tracked

  • set fbq.allowDuplicatePageViews = true after disable pushState

moustafaMahran avatar Oct 24 '21 14:10 moustafaMahran

Is anyone maintaining this repo??

danwetherald avatar Nov 14 '21 20:11 danwetherald

https://www.npmjs.com/package/@bettercart/react-facebook-pixel

danwetherald avatar Nov 14 '21 20:11 danwetherald

Hi, there are still no way of handling dedplication of events as of December of 2023 ? Thanks guys !

taqiycarbon avatar Dec 02 '23 14:12 taqiycarbon