> For the complete documentation index, see [llms.txt](https://docs.adpage.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.adpage.io/integrations-marketingtools/meta-ads/setting-up-client-side-meta-ads-tracking-with-deduplication.md).

# Setting up client-side Meta Ads tracking with deduplication

Setting up client- and server-side tagging for Meta Ads with event\_id deduplication

Running both server-side and client-side tagging means Meta receives the same conversion twice: once from the browser and once from your server. Deduplication is what stops that from being counted twice. It works when both events carry the **same event name** and the **same event\_id**. Meta then keeps one and discards the duplicate, preferring the server event, which is the more reliable of the two.

So the goal throughout this guide is that your Meta Pixel tag, your GA4 tag and your server-side Conversions API tag all describe the same interaction with the same event ID.

### Before you start

Make sure you have:

* [ ] A working [server-side Conversions API setup](/integrations-marketingtools/meta-ads.md).
* [ ] Your **Meta Pixel ID**. See [How to find your Meta Pixel ID](/integrations-marketingtools/meta-ads/where-to-find-the-meta-pixel-id-and-the-meta-api-token.md).
* [ ] A **Unique Event ID** variable in your web container.

### Step 1: Add the tag template

1. Open your GTM web container and go to **Templates**.
2. Under **Tag Templates**, click **Search Gallery**.
3. Search for the **Meta Pixel** tag template and add it to your workspace.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2FoqUb2R0Qr1j9tve2uncE%2Fimage.png?alt=media&amp;token=b2addb86-728a-438a-ac30-86e10cae9600" alt=""><figcaption></figcaption></figure>

### Step 2: Create a variable for your Pixel ID

4. Go to **Variables**.
5. Create a new **User-Defined Variable** and choose **Constant** as the variable type.
6. Enter your Meta Pixel ID as the value and save the variable.

{% hint style="info" %}
Using a constant variable rather than typing the ID into each tag means you only have one place to change it later.
{% endhint %}

### Step 3: Create your Meta event tags

1. Go to **Tags** and create a new tag. Select the **Facebook Pixel** template as the tag configuration.
2. In the **Meta Pixel ID** field, select your Pixel ID variable.
3. Under **Event Name**, indicate whether this is a standard or a custom event. Select a standard event from the dropdown menu, or type a custom event name into the input field.
4. Expand **More Settings**. In the **Event ID** field, enter your Unique Event ID variable.
5. As the trigger, select the same trigger you use for the GA4 event tag covering this interaction.
6. Save the tag. And repeat for the other events and conversions you want to set up.

{% hint style="warning" %}
Don't forget to set up the page\_view tag, and use the same trigger as your GA4 page\_view event tag.
{% endhint %}

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2FMaxvl2fB1GhwuKiTOZ5m%2Fimage%20(53).png?alt=media&amp;token=ae9f7556-ffd6-47b7-ab80-b380857a3871" alt=""><figcaption></figcaption></figure>

### Step 4: Add the event\_id to your GA4 events

Your GA4 event tags are what feed the server container, so the event ID has to travel with them. For every interaction you want to deduplicate, add your **Unique Event ID** variable as an event\_id event parameter on the GA4 event tag that fires on that interaction.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2F0BpvIPXyTvkYHyJ7C8QB%2Fimage.png?alt=media&amp;token=3347dd2c-d02c-42e2-b5cd-a0c12191dc2e" alt=""><figcaption></figcaption></figure>

### Step 5: Test and Verify

Open Google Tag Manager's preview mode to check whether the event\_id in the client-side Meta Event tag matches the server-side Facebook Conversion API tag. If this is not the case, the usual causes are:

* The event names do not match. The Pixel sends one name and the server-side tag sends another.
* The event IDs do not match, or the server-side tag receives no event ID at all.
* The two tags fire on different triggers, so they never describe the same interaction.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.adpage.io/integrations-marketingtools/meta-ads/setting-up-client-side-meta-ads-tracking-with-deduplication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
