zsajjad / react-facebook-pixel

React JS wrapper for Facebook's Pixel
MIT License
233 stars 86 forks source link

Support options argument in tracking functions #57

Open asheba opened 4 years ago

asheba commented 4 years ago

The fbq track function allows passing another JSON object argument with options - one of which, eventID, is used for deduplication with server-side reporting.

This is documented here: https://developers.facebook.com/docs/marketing-api/conversions-api/deduplicate-pixel-and-server-events

asheba commented 4 years ago

@zsajjad Any chance to review + merge this one? It's just passing another argument 🙏

claygorman commented 4 years ago

@zsajjad I too would love to see this PR merged

martink-rsa commented 3 years ago

I sadly just removed this library because it didn't support passing the eventId for deduplication, eventually leading me to this thread/PR.

You should really add this, it's gamebreaking to be able to pass the eventId to prevent duplication.

Vegeta-47 commented 3 years ago

For the love of god, merge this commit plz

Vegeta-47 commented 3 years ago

@martink-rsa did u use another package, how did u fix the issue ?

martink-rsa commented 3 years ago

Hi @Vegeta-47 ,

I reverted to the manual way of setting it.


window.fbq("init", pixelId)
window.fbq("track", "PageView")

function fbPixel(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)
}

Later on I called it again with the id I needed to pass:

 window.fbq("track", "Purchase", { value, currency }, { eventID: token })
Vegeta-47 commented 3 years ago

Thanks for replying @martink-rsa, ill do the same

houmark commented 3 years ago

@zsajjad This was approved but never merged? Would you consider merging in and releasing pending PR's or sharing access to the repository so someone else can do it? I'd volunteer to help out if you are too busy.

We really need this third argument as de-duplication is really important these days. Another option would be spinning off a new package based on this one (our build platform is not accepting forks :/).

danwetherald commented 3 years ago

Why has this not been merged?