facebook-nodejs-business-sdk icon indicating copy to clipboard operation
facebook-nodejs-business-sdk copied to clipboard

How to pass eventId using this api?

Open rschlack opened this issue 3 years ago • 4 comments

I'm using this package to send server side events to facebook. On the client I can set an eventId to uniquely identify the event and pass that down to the server where I'd like to send it too. This is required for deduplication. How do I add an eventId to my server event?

rschlack avatar Nov 29 '21 15:11 rschlack

There's an option using the server event to use "setEventId" (found it somewhere in the internet) But it doesn't seem to work. So I'm joining the question too. It seems when using EventRequest, the eventId of the server event is neglected and not being used. It's missing here. Though it looks like an event of multiple instances of server event, so not sure why it's not being used.

hagar-dolev avatar Jan 24 '22 08:01 hagar-dolev

Although it wasn't in the docs, I was able to get it from the source code in Github. My serverEvent setup looks like the following and it's working for me. But I had to generate the unique eventId on the client-side, use it in the client FB tracking call and then pass that same clientId to the server. That clientId shows in the FB ad manager site as matching up now.

Client side: fbq("trackCustom", event, {}, {eventID: eventId});

Server side: const serverEvent = new ServerEvent() .setEventName(event) .setEventTime(current_timestamp) .setUserData(userData) .setEventSourceUrl(url) .setActionSource("website") .setEventId(eventId);

rschlack avatar Jan 24 '22 13:01 rschlack

That's interesting, for some reason it doesn't work for me and the eventId is not recognised inside the Business Manager. I'll try perhaps some other configurations. Thanks for the confirmation it does work for you.

hagar-dolev avatar Jan 24 '22 19:01 hagar-dolev

I assume https://github.com/facebook/facebook-nodejs-business-sdk/pull/216 would be related.

gitusp avatar Mar 08 '22 01:03 gitusp