Meta Pixel and Conversions API with deduplication
The Meta Pixel runs in the browser, so ad blockers and browser restrictions stop some of its events. The Conversions API (CAPI) sends the same events from your server container, which is far harder to block. Meta recommends running both. The catch is that each conversion then arrives twice, so you give both copies the same event ID and Meta keeps one.
Advanced 12 min read
What you will learn
- Send Meta Pixel events from the web container with an
event_id. - Forward the same
event_idto the server container with the GA4 hit. - Set up a Conversions API tag in the server container.
- Confirm in Events Manager that browser and server events are deduplicated.
01 How deduplication works
Meta treats a browser event and a server event as the same event when they come from the same Pixel with the same event_name and the same event_id, and arrive within 48 hours of each other. It keeps one and drops the other.
- The event name must match exactly, for example
Purchasein both. - The
event_idmust be identical in both, so it has to be created once, in the browser, and shared. - The
_fbpand_fbccookies help Meta match the server event to the visitor. Because the GA4 hit goes to your own subdomain, the browser sends these cookies with it and the server tag can read them.
02 Create the event ID in the web container
Generate a unique ID when the event happens and push it to the dataLayer together with the event.
const eventId = crypto.randomUUID();
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ ecommerce: null });
window.dataLayer.push({
event: 'purchase',
event_id: eventId,
ecommerce: {
transaction_id: 'T-10293',
value: 129.90,
currency: 'EUR',
items: [{ item_id: 'SKU-1', item_name: 'Shoes', price: 129.90, quantity: 1 }]
}
});- 1 In the web container create a Data Layer Variable with the name
event_id. - 2 In your Meta Pixel tag (from the Community Template Gallery or your existing setup) set the event name to
Purchaseand the Event ID field to{{DLV - event_id}}. - 3 Open the GA4 event tag that sends
purchaseand add an event parameterevent_idwith the value{{DLV - event_id}}. The ID now travels to the server container inside the GA4 hit. - 4 Publish the web container once Preview shows the same ID in both tags.
03 Add the Conversions API tag in the server container
First get an access token: in Events Manager select your Pixel, open Settings, scroll to Conversions API and click Generate access token. Keep the token secret, it can send events to your Pixel.
- 1 In the server container go to Templates, then Tag Templates, and click Search Gallery. Add a Conversions API template, such as Meta's own Conversions API Tag or the one by Stape.
- 2 Create a new tag from the template. Enter your Pixel ID and the access token.
- 3 Map the event name (GA4
purchaseto MetaPurchase) if the template does not do it for you. - 4 Make sure the event ID comes from the
event_idevent parameter. Most templates read it automatically. - 5 Trigger the tag on a Custom trigger where Client Name equals
GA4and Event Name equalspurchase.
04 Test in Events Manager
- 1 In Events Manager select your Pixel and open Test events. Copy the test code (it looks like
TEST12345). - 2 Paste it into the Test Event Code field of the server tag and publish, or test in server Preview.
- 3 Trigger the event on your site. Both a Browser and a Server event should appear.
- 4 Check that they are marked as deduplicated. If they are not, compare the event name and
event_idof both. - 5 Remove the test event code when you are done, otherwise live events keep landing in Test events.
- The Pixel event and the GA4 hit carry the same
event_id. - The server Preview shows the Conversions API tag fired with a 2xx response.
- Events Manager shows browser and server events deduplicated.
- The test event code is removed from the live tag.
Frequently asked questions
Can I use only the Conversions API and drop the Pixel?
You can, but Meta recommends both. The Pixel collects browser signals the server does not see, and the server covers visitors whose browser blocks the Pixel. Deduplication keeps the count correct.
Why does Events Manager count my purchases twice?
The two events do not share the same event name and event_id. Check that both tags read the ID from the same dataLayer push, and that the server tag receives the event_id parameter from the GA4 hit.
Where do `_fbp` and `_fbc` come from on the server?
The Pixel sets them in the browser. Because your GA4 hits go to a subdomain of your site, the browser sends these cookies along, and the Conversions API template reads them from the request.
Ready to put it into practice?
Deploy a server GTM container on your own domain in a few minutes. The Free plan needs no card.
Create a free account