# JENTIS Facebook Tracking Implementation

With the Pixel, Conversion API (CAPI), and events prepared in Facebook Business Manager, the last step is to configure the actual implementation in **JENTIS Tag Manager (JTM)**.

The JENTIS integration ensures that both **frontend (browser pixel)** and **server-side (CAPI)** tracking are aligned, deduplicated, and enriched with high-quality data.

### 1. Create and Configure the Facebook Tool

1. Navigate to **Server Tag Management → Tools** in your JTM account.
2. Create a new **Tool** and select **Facebook**.
3. Fill in the mandatory parameters:
   * **Pixel ID** → from your Facebook Business Manager
   * **Access Token** → generated when enabling CAPI
4. Optionally set:
   * **Partner Agent String** → for debugging
   * **Test Event Code** → to verify events in Facebook Test Events

👉 The Pixel ID is used for **client-side tags**, the Access Token for **server-side tags**.

### 2. Create and Configure a Facebook Tracker

1. Go to **Trackers** in JTM.
2. Add a new **Facebook Tracker**.
3. This tracker acts as the central reference object for all Facebook-related tags.
4. It connects frontend and server-side events to the same Pixel.

### 3. Frontend Tracking Setup

1. Review the data points already available in your JENTIS setup.
2. Add extra **events and parameters** required for Facebook (e.g., `Purchase`, `Lead`, PII data).
3. Make sure PII (such as email, phone) is **hashed** client-side before being submitted to JTM.

Example of pushing a hashed email:

```js
var emh = sha256("mail@address.com"); 

_jts.push({
  track: "event",
  group: "fbpii",
  name: "emh",
  emh: emh
});
```

In **Preview Mode** of JTM, you should see the event arriving with the hashed value.

### 4. Server-Side Tag and Trigger Setup

#### Create a Tag

1. Navigate to **Tags** → Create new tag.
2. Select the **Facebook Tracker** and the **event template** (e.g., `Purchase`, `Lead`).
3. Map required parameters:
   * `em` → references `emh` (hashed email from frontend event)
   * `fbc`, `fbp` → mapped automatically by JENTIS
   * Pixel ID + Access Token → reference from Tracker

#### Create a Trigger

1. Navigate to **Triggers** → Create new trigger.
2. Define the conditions for when the tag should fire.
   * Example: Fire when event group = `fbpii`.
3. Attach the trigger to the tag.

Now, whenever the event occurs, JENTIS will send the data to **Facebook CAPI**.

### 5. Debugging & Verification

* Use **JTM Preview Mode** to check incoming data.
* Use the **Test Event Code** in your Pixel to verify events are arriving in Facebook in real time.
* Ensure deduplication is set up if both frontend and server-side send the same events.

### 6. Go Live

Once testing is complete:

1. Remove or disable the test code.
2. Publish the configuration in JENTIS.
3. Monitor event delivery and quality in **Facebook Business Manager → Events Manager**.

{% hint style="success" %}
With this implementation, JENTIS ensures that **frontend and server-side Facebook tracking** are synchronized, privacy-compliant, and optimized for event quality.
{% endhint %}
