Read 'event_id' of tracked events for third party integration

Hello, Snowplow Dev Team,

My team and I are currently using Snowplow and trying to integrate it with Facebook Pixel (but planning to add more third party in the future). The requirement for Facebook Pixel is that we have to provide ‘event_id’. We want to use the ‘event_id’ that Snowplow has generated so that both event log in Snowplow and Facebook is able matched with each other and can easily joined for analytic purpose.

Do Snowplow has feature, callback, or anything that able to access the generated ‘event_id’? I do noticed that Snowplow has tracker callback that have method to access the DomainUserInfo, PageviewID, and CookieName, but no ‘event_id’ is available, thus we cannot use it.

Thank you!

Hi @aldoarya
Welcome to the Snowplow Community!
Kind regards,
Eddie

1 Like

There’s no native method to do so but you could use a plugin to retrieve this data and then process it in any way you want (it’s worth noting for your use case however that event_id is somewhat, but not guaranteed to be unique).

 window.snowplow('newTracker', 'sp', 'http://....', {
      appId: 'my-app-id',
    });

    const plugin = {
      ExamplePlugin: function () {
        return {
          beforeTrack: (payloadBuilder) => {
            const payload = payloadBuilder.getPayload();
            const eventId = payload['eid'];
            // do something with eventId
            
          }
        };
      },
    };
    
    window.snowplow('addPlugin', plugin, 'ExamplePlugin');
1 Like

I see. Thanks for the reply!.

Sorry for missing the detail that we are using Tracker V2, but I suppose this custom plugin is only available to Tracker V3, right?
Is there any equivalent way to gain this in Tracker V2?

Yes, plugins are just for V3 at the moment. I don’t believe there is a way to easily do this in the Javascript tracker that I can think of and it’s not yet possible to set the event_id manually.

If you want to achieve the same thing I’d recommend generating your own UUID at event time and attaching this as a context and sending that value through to Facebook as well which will ensure that you’ll have full control in generating and fetching it.

1 Like

Unfortunately I can’t think of an reasonable alternative in V2.

Upgrading to V3 might not be a huge effort, I think that’d be worth investigating. There are two main breaking changes to watch out for, which are documented here: Migrating from v2 to v3 - Snowplow Docs

V3 release info: Introducing Version 3.0 of the Snowplow JavaScript Trackers (Browser and Node.js)

One other idea… you could generate your own ID and add it as a context to the events.

That’d mean build your own schema which has a uuid property in it. You could then generate your own ID and track it with the context on your event (perhaps even using Global Contexts so it’s on every event) and with the Facebook Pixel.

I see…
Thanks for the help! We might consider using the context as our chosen option right now.

Anyway, have a good day!