This guide sets up the Meta Conversions API in a Google Tag Manager server container, end to end: the browser stream into the server, Meta’s own Conversions API Tag, the deduplication ID, and the Test Events check that proves it. If you need the basics first, such as what the API is, how it differs from the Pixel and what it costs, read the Facebook Conversions API guide. If you’d rather not run a container at all, the Conversions API Gateway guide covers Meta’s managed alternative.
I run tracking implementations for clients, and I built Advanced Tracking Academy around the containers I deploy in production. The gotchas below come from wiring our own containers, with dates.
What you need before starting
- A Meta dataset (Pixel) ID and an access token. For a production server, use a system user in Business Settings with access to the dataset, and generate its token there, so tracking survives staff changes.
- A GTM server container on a host, reachable on a first-party subdomain such as
data.yourdomain.com. The server-side GTM guide covers hosting. - The browser Meta Pixel already firing the events you want to mirror, so there is something to deduplicate against.
- A consent decision that gates both legs. A visitor who declines gets no Pixel event and no Meta server event. The server moves where the event leaves from, not whether you may send it.
How the event travels from the page to Meta
- The web container’s GA4 event tags send to your server container instead of straight to Google, through the
server_container_urlsetting on the Google tag. To the browser this is first-party traffic, though a request from the browser to your subdomain can still be blocked. - In the server container, the GA4 client claims those requests and turns each one into event data that every server tag can read.
- Meta’s Conversions API Tag reads that event data and posts it to Meta. The Google Ads, GA4 and TikTok Events API tags read the same event.
Configuring Meta’s Conversions API Tag
The tag is “Conversions API Tag” by facebookincubator, in GTM’s community template gallery. Its fields are Pixel ID, API Access Token, Test Event Code and Action Source (set it to website for web events). Everything else comes from the event data, and reading the template’s source (checked 2026-10-17) shows exactly where:
| Meta field | Read from the event data |
|---|---|
event_name |
The GA4 event name, translated: purchase to Purchase, generate_lead to Lead, begin_checkout to InitiateCheckout, page_view to PageView |
event_id |
A parameter named event_id |
event_source_url |
page_location |
client_ip_address, client_user_agent |
ip_override and user_agent, which the GA4 client fills from the request |
fbp, fbc |
x-fb-ck-fbp and x-fb-ck-fbc, or the _fbp and _fbc cookies on the request |
em |
user_data.email_address, hashed by the tag |
custom_data.order_id |
transaction_id |
Note the last row. The tag puts transaction_id into order_id, not into event_id. If you want the order ID to deduplicate a Purchase, you have to send it as event_id as well.
Fire the tag on the GA4 client’s events, filtered to the event names you send to Meta. Pass the visitor’s email in the GA4 event’s user_data only when the page collected it with consent; the Meta tag hashes it before sending.
The event_id mapping that silently breaks deduplication
Meta’s deduplication documentation has two conditions, and both must hold: the Pixel’s eventID matches the server’s event_id, and the Pixel’s event name matches the server’s event_name. The pair also has to arrive within 48 hours of the first event with that ID. A matching ID under different names does not deduplicate.
The ID has to be generated once and reach both legs. Here is where it went wrong for us. When we wired our own containers through the GTM API on 2026-09-27, a GA4 event parameter called event_id left the browser as gtag’s reserved evnid field, not as a custom parameter. Whether the server’s GA4 client maps evnid back to event_id for the Meta tag is not documented anywhere we could find. A container can look correct in the web Preview and still send Meta a server event with no ID, so check the incoming event data in server Preview before you rely on event_id.
The workaround we use: send the ID under a plain name, meta_event_id, and copy it to event_id with a server transformation that applies only to the Meta tag. The same session turned up a second trap. A transformation scoped to the GA4 tags must exclude the Meta tag, or it can strip ip_override and user_agent from it, and client_user_agent is required for website events.
For Purchase, use the order or transaction ID as the ID on both routes. If the server event comes from a payment webhook that never sees the page, either use the order ID or store the page-generated ID against the checkout record so the webhook can look it up. The order-ID deduplication guide covers that contract and its tests. Page-generated IDs are fine for events with no transaction behind them, such as Lead.
Testing with Test Events before you publish
Server events only show in Meta’s Test Events tab when the request carries the test_event_code from that tab (Using the API, checked 2026-10-17). This is how we proved deduplication on 2026-09-27 without touching the live container:
- Copy the code from Events Manager, Data Sources, your Pixel, Test Events.
- Paste it into the Meta tag’s Test Event Code field in an unpublished workspace.
- Open server Preview and web Preview together, and trigger the event.
- In Test Events, both rows should carry the same event name and ID, with one copy processed and its duplicate marked deduplicated. Which route gets which label depends on arrival order. In our run the browser row read “Desduplicado” and the server row “Processado”, because our Events Manager runs in Portuguese.
- Clear the field, so the workspace goes back to zero changes.
Meta’s documentation adds a warning: events sent with test_event_code are not dropped. They flow into Events Manager and count for targeting and measurement. Keep test purchases rare and clearly marked.
One more trap if you automate the check. In a lab reproduction on 2026-10-06, with a real dataset’s signals configuration, Meta’s Pixel library (fbevents.js as served that day) sent nothing from a browser whose user agent contained HeadlessChrome. With the default headless user agent your test sees a server event and no browser event, and it looks like broken deduplication. Set an ordinary Chrome user agent.
Sending purchases from the payment webhook
Deduplication stops one purchase counting twice. It doesn’t stop a thank-you page reload, a bot or a failed payment from counting at all. For that, the Purchase should come from your payment processor’s webhook, matched to the stored browser session, before the server sends it to Meta. Every server Purchase then maps to a confirmed successful payment; refunds and disputes stay separate events. The browser Purchase needs the same gate, or a thank-you page can still report an unpaid checkout: fire the Pixel only after the page has read a paid status from your backend (for Stripe Checkout, the session’s payment_status of paid), with the same event ID as the server copy.
The webhook handler needs four checks: verify the signature, read the authoritative payment status rather than the event name alone, wait for delayed payment methods to clear, and ignore a retry it already processed. The Stripe conversion tracking guide walks through them.
Hosting and the Gateway alternative
Meta charges nothing to receive events; you pay for the container’s host. The Facebook Conversions API guide has current, dated figures for a managed host and for Google Cloud Run, where Google recommends at least two instances at about $45 a month each. If Meta is your only platform and you don’t need webhook validation, the Gateway versus server-side GTM comparison explains when the managed Gateway is enough.
If you set up CAPI for several clients and want each order sent once, the same way every time, ATA Edge sends one Purchase per order from your own Cloudflare account, and the membership includes a library of server GTM containers as a bonus.