How to prevent Facebook Pixel to track the same transaction twice?

Viewed 808

In my Purchase confirmation page, I send the purchase info to Facebook. But if my user hits Refresh, the data is sent again and Facebook compile the purchase values twice.

With Google Analytics, we can send a Transaction ID and even if the user refresh the page, the data is compiled only once.

Is there a way to achieve the same thing with Facebook? I would prefer to let Facebook do the job instead of having a flag on my side to send the Pixel only once.

Thanks

2 Answers

I solved this issue using sessions. Before you render purchase page you can set some session flag which trigger rendering FB pixel code (or whathever) => after rendering this code you can remove this session. If your customer refresh page session will be not set so your FB pixel code will be not rendered twice.

I used this idea in my extension for Nette framework: Eflyax/facebook-pixel

I also was looking for a similar feature to Google Analytics's Transaction ID to deduplicate events.

So it turns out that Facebook does have such a parameter. Facebook calls it the eventID and it's used like this:

fbq('track', 'Purchase', {value: 12, currency: 'USD'}, {eventID: 'EVENT_ID'});

You can find the documentation of this parameter here: Facebook docs

Related