# Tracking Facebook Pixel

Available on the **STARTER** plan and above

#### Step 1: Add the following JS code after the Trigger action block <a href="#step-1-add-the-following-js-code-after-the-trigger-action-block" id="step-1-add-the-following-js-code-after-the-trigger-action-block"></a>

Immediately after the Trigger block, add a Javascript block and add the code shown below. This initialises the pixel code so that it can start listening to tracking events fired from the chatbot.

Copy

```
!(function (f, b, e, v, n, t, s) {
  if (f.fbq) return;
  n = f.fbq = function () {
    n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);
  };
  if (!f._fbq) f._fbq = n;
  n.push = n;
  n.loaded = !0;
  n.version = "2.0";
  n.queue = [];
  t = b.createElement(e);
  t.async = !0;
  t.src = v;
  s = b.getElementsByTagName(e)[0];
  s.parentNode.insertBefore(t, s);
})(
  window,
  document,
  "script",
"https://connect.facebook.net/en_US/fbevents.js"
);
fbq("init", "YOUR_FACEBOOK_PIXEL_ID");
```

Make sure you replace YOUR\_FACEBOOK\_PIXEL\_ID with the actual value.

#### Step 2: Add the fire events code <a href="#step-2-add-the-fire-events-code" id="step-2-add-the-fire-events-code"></a>

Now, we will add the events that needs to be tracked on your pixel. To do this add a Javascript block immediately after the block whose event you want to track.

For example, in the screenshot below I want to track the event when someone fills the form after choosing **Talk to sales.**

Tracking a "Lead" event when the form is filled

<figure><img src="https://help.wotnot.io/~gitbook/image?url=https%3A%2F%2F360969599-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FsrMxU8nO3RjusUiYuXBB%252Fuploads%252FHfHIiNzYr5dqgpZMsF8S%252FCleanShot%25202023-11-30%2520at%252010.17.53.png%3Falt%3Dmedia%26token%3Dbce7f3fc-ea4a-4ce8-9064-c4349b97581d&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=7ea55ce1&#x26;sv=1" alt=""><figcaption></figcaption></figure>

We need to use a Javascript block after the block that you want to track, and add the event tag.

You can find the standard events supported by Facebook here 👉 <https://en-gb.facebook.com/business/help/402791146561655?id=1205376682832142>

\ <br>


---

# Agent Instructions: 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:

```
GET https://help.wotsabot.ai/wotsabot-help-articles/trouble-shooting/tracking-facebook-pixel.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
