vIceBerg
vIceBerg

Reputation: 4317

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

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

Upvotes: 6

Views: 2127

Answers (2)

Eflyax
Eflyax

Reputation: 5847

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

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

Upvotes: 1

Marnix.hoh
Marnix.hoh

Reputation: 1922

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

Upvotes: 0

Related Questions