> For the complete documentation index, see [llms.txt](https://doc.commandersact.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.commandersact.com/features/destinations/destinations-catalog/facebook/facebook-conversions-api/facebook-capi-through-gtm.md).

# Facebook CAPI through GTM

Commanders Act provides a GTM template to connect your existing GTM implementation to our serverside endpoint, enabling "Facebook CAPI" in a secured environment.

### Setup

1. Add our bridge tag
2. Update your Facebook tags

### 1. Add our bridge tag

First, access [GTM ](https://tagmanager.google.com/)and then add our template "**Commanders Act | Serverside events bridge**"\
You can follow our dedicated guide:

{% content-ref url="/pages/6a4S0tgj4uWNAzl3Vhu7" %}
[Google Tag Manager (GTM)](/features/sources/sources-catalog/web/gtm.md)
{% endcontent-ref %}

### 2. Update your Facebook tags

If you're planning to keep running your existing Facebook pixels while using "Facebook CAPI" through GTM, it's really important that you update them following these guidelines. This will allow to deduplicate and keep consistent measurements of your events.

The process is straightforward as for every event you're sending via pixel tags you just need to add the event identifier - On GTM, open your "Facebook Pixel" tag and expand (14) "**More Settings**" to locate the "**Event ID**" and click (15) its icon on the right.

![](https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-8f4aea03b91f6b93559f0878b24c8cd4f625ca49%2F9.png?alt=media)

A new window will slide-in. Click on `(16)` the **plus on the top right.**

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-2f93b77c6ba9b923e56cac8f83d45ab401118600%2F10.png?alt=media" alt=""><figcaption></figcaption></figure>

Click on `(17)` the "**Variable Configuration**".

![](https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-922cffab7f50b0300a9888b9574e011d4ff9a008%2F11.png?alt=media)

Click `(18)` the "**JavaScript Variable**".

![](https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-deb56df1a31360ba31bf0048b92e1643b32f47e2%2F12.png?alt=media)

Rename your `(19)` variable as ***window\.tC.uniqueEventId*** and set the same name in `(20)` the "**Global Variable Name**" then click `(21)` the "**Save**" button.

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-c4bf55ec2b03e8fa5abdfee1dd8c91cedfc4867b%2F13.png?alt=media" alt=""><figcaption></figcaption></figure>

Back on the tag configuration, expand `(22)` "**Advanced Settings**" and `(23)` "**Tag Sequencing**" to check `(24)` the option "**Fire a tag before Facebook Pixel fires**". In "Set-up Tag", select `(25)` "*Commanders Act | Serverside events bridge*" and save your tag.

![](https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-b1d40519a524997f17685599ff313ebc825b125c%2F14.png?alt=media)

{% hint style="success" %}
Repeat this configuration for each active "Facebook Pixel" in GTM.
{% endhint %}

{% hint style="info" %}
See Facebook documentation for more details: [Deduplicate Pixel and Server Event](https://developers.facebook.com/docs/marketing-api/conversions-api/deduplicate-pixel-and-server-events)
{% endhint %}

{% hint style="info" %}
Contact your reference consultant or our [Support team](mailto:support@commandersact.com) in case you need assistance.
{% endhint %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://doc.commandersact.com/features/destinations/destinations-catalog/facebook/facebook-conversions-api/facebook-capi-through-gtm.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
