TrackLead
←All articles

Set up the Meta Conversions API with server-side GTM

4 min read

Short answer: you send the same events through the Meta Pixel in the browser and through the Conversions API from your server container, with a unique event_id that is identical in both. Meta deduplicates events with the same event_id and event_name that arrive within 48 hours. You need the dataset ID (Pixel ID), an access token and a working server container. Test with Test Events and then check Event Match Quality.

What you need

  • Access to the dataset (the Pixel) in Meta Business Manager, with at least rights to manage settings.

  • A Conversions API access token. You create it in Events Manager in the dataset settings.

  • A server container on a subdomain of the site, with a working GA4 client or your own client. What to sort out: setting up server-side tracking.

  • A data layer that pushes an event with value, currency and a unique ID to the web container for every purchase or lead.

Step 1: event_id in the web container

Generate one unique ID per event, for example the order number for a purchase or a random string for a lead. Use that ID as eventID in the Meta Pixel tag and send it to the server container (for example as a parameter in the GA4 event). Without that ID, Meta can’t link pixel and API.

Step 2: the Conversions API tag in the server container

  • Add a Meta Conversions API tag to the server container (a template from the gallery).

  • Enter the dataset ID and the access token. Store the token as a variable, not in plain text across several tags.

  • Map the event name to Meta’s standard events: Purchase, Lead, AddToCart, InitiateCheckout.

  • Send event_id with exactly the same value as in the Pixel.

  • Send customer data you have a legal basis for: email and phone (hashed with SHA-256), the _fbp and _fbc cookies, IP address and user agent.

Step 3: check deduplication

Meta deduplicates a pixel and a server event when event_name and event_id match and they arrive within 48 hours of the first event. In Events Manager you see per event whether the browser and server versions were merged. If a purchase counts twice, the event_id is usually wrong on one side. More on duplicate conversions follows in a separate blog.

Step 4: testing

  1. Open Test Events in Events Manager and add the test code to the Conversions API tag.

  2. Place a test order or test lead and check the event arrives through browser and server, with the same event_id.

  3. Also test with declined cookies: then no event with personal data may go to Meta.

  4. Remove the test code before you publish.

Step 5: improve Event Match Quality

Event Match Quality is a score from 0 to 10 in Events Manager. It shows how well Meta can match your events to people. A higher score means more events count for your campaigns. You improve it by sending more customer data you have a legal basis for, especially a hashed email address and _fbc (the click ID).

Common mistakes

  • Different event_ids in Pixel and API: everything counts twice.

  • Different event names, such as purchase in the API and Purchase in the Pixel: no deduplication.

  • Consent not passed to the server container: you send more than you are allowed to.

  • Test code left in after go-live: events only end up in Test Events.

Want to know in plain language what a conversion API is first? Read conversion APIs explained.

TrackLead makes sure sales and leads reach Google, Meta and LinkedIn properly, and tells you when something breaks. Take a look at tracklead.eu.

Frequently asked questions

Should I keep the Meta Pixel when I use the Conversions API?

Yes. Meta recommends using both together. With the same event_id each event counts once.

Within what time does Meta deduplicate?

According to Meta, events with the same event_id and event_name are deduplicated when they arrive within 48 hours of the first event.

Where do I find the access token?

In Events Manager, in the dataset settings, under the Conversions API. You generate the token there.

What is a good Event Match Quality?

The higher the better; the score runs from 0 to 10. Where allowed, send a hashed email address and the click ID to raise it.