> For the complete documentation index, see [llms.txt](https://support.agentfire.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.agentfire.com/integrations/facebook/articles-1505057-how-to-set-up-a-facebook-pixel.md).

# How to Add a Meta (Facebook) Pixel to Your Website

Add your Meta (Facebook) Pixel to your AgentFire website, fix the 'tag not allowed' error, track leads on a thank-you page, and check that it works.

The Meta Pixel lets Facebook and Instagram ads see who visits your website and who becomes a lead. You get the code from Meta, then paste it into one box on your website.

## Get your Pixel code from Meta

In Meta **Events Manager**, create a pixel (or open the one you already have) and choose to **install the code manually**. Copy the code Meta shows you. Meta's own steps are here: [Set up a Meta Pixel](https://www.facebook.com/business/help/952192354843755).

Meta now groups pixels under **Datasets**. If you already have a pixel, use that one rather than making a new one.

## Add the code to your website

{% stepper %}
{% step %}

### Open Header/Footer Scripts & Metas

Click the menu icon at the top left, then **Site Settings** > **AgentFire Settings** > **Header/Footer Scripts & Metas**.
{% endstep %}

{% step %}

### Remove the noscript part

Meta's code ends with a part that starts `<noscript>` and ends `</noscript>`. Cut that part out, from `<noscript>` to `</noscript>`: the head box won't save with it in. If you want to keep it, paste it into **Body before closing tag** instead. It only matters for visitors who have JavaScript turned off.
{% endstep %}

{% step %}

### Paste it into Head first

Paste the rest of the code into the **Head first** box (it used to be called **Facebook Pixel Code**). It should start with `<!-- Meta Pixel Code -->` and `<script>`.

![The Head first box with the pixel code pasted in](https://2039430885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fq65vhH2v4k5rpDOha9Vm%2Fuploads%2Fgit-blob-b41530724b871c7f60976ad05a2da6792c1f1414%2Fpixel-1-paste.png?alt=media)
{% endstep %}

{% step %}

### Click Update

Click **Update** on the right. You'll see **Options Updated**. The pixel is now on every page of your website.
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
**Head first** is the box for analytics and marketing scripts, so Google Analytics, Google Tag Manager and Hotjar go there too. If your site has a cookie banner, set the box's category to **Analytics & Marketing**. See [Where each script goes](/faqs-and-general/common-questions/articles-cookie-banner.md#where-each-script-goes).
{% endhint %}

After you save, you may see a message asking whether to turn on the **cookie banner**. You can turn it on yourself: see [How to Set Up the Cookie Banner](/faqs-and-general/common-questions/articles-cookie-banner.md). With the banner on, the pixel only runs for visitors who accept cookies.

![The notice asking whether to turn on the cookie banner](https://2039430885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fq65vhH2v4k5rpDOha9Vm%2Fuploads%2Fgit-blob-bce263ab3ce8efd0240d07918e91de8b3e35ecc3%2Fpixel-3-cookie-prompt.png?alt=media)

## Track leads on a thank-you page (optional)

If your form sends people to a thank-you page, you can tell Meta that each visit to that page is a lead. The pixel must already be on your site (above).

{% stepper %}
{% step %}

### Open the page's WordPress settings

Open the thank-you page in the editor and click the **WordPress Settings** icon (the "Y") in the toolbar. The page's settings open in a new tab.

![The WordPress Settings icon in the editor toolbar](https://2039430885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fq65vhH2v4k5rpDOha9Vm%2Fuploads%2Fgit-blob-098d795c47f7275f6d71b68bb6cea1aca902f8cb%2Fpixel-0-wp-settings.png?alt=media)
{% endstep %}

{% step %}

### Add the event

Scroll to **Facebook Pixel Events**. Set **Insert Facebook Pixel Events code on this page** to **Yes**, and paste the event code into the box. For a lead, that's `fbq('track', 'Lead', {});`. Then click **Update** in the **Publish** box on the right.

![The Facebook Pixel Events panel](https://2039430885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fq65vhH2v4k5rpDOha9Vm%2Fuploads%2Fgit-blob-3d8e054943706a4998a71f2b5b6af3f63220a83b%2Fpixel-4-page-events.png?alt=media)
{% endstep %}
{% endstepper %}

This box is only for event lines like the one above. Never paste your whole pixel code here.

## Check that it works

Add Meta's free **Meta Pixel Helper** extension to Chrome. Open your website, accept cookies if a banner shows, and click the helper. It should show your pixel and a **PageView**. In Events Manager, it can take a while before Meta shows the pixel as active.

## Common Questions

<details>

<summary>It says "This tag not allowed in &#x3C;head>: &#x3C;img>".</summary>

The `<noscript>` part of Meta's code is still in the box. Delete everything from `<noscript>` to `</noscript>` and click **Update** again.

![The "This tag not allowed in head: img" error above the Head first box](https://2039430885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fq65vhH2v4k5rpDOha9Vm%2Fuploads%2Fgit-blob-441d260a8b0620ac58915972aa6f1edeb498a5ad%2Fpixel-2-img-error.png?alt=media)

</details>

<details>

<summary>Meta says my pixel isn't active.</summary>

Check your site with Meta Pixel Helper, after accepting cookies if your site shows a cookie banner. If the helper finds no pixel, check that the code is saved in **Head first** and the pixel ID matches the one in Events Manager.

</details>

<details>

<summary>Can I have the pixel on only one page?</summary>

The **Head first** box puts it on every page. To have it on one page only, email <support@agentfire.com> with the page.

</details>

<details>

<summary>Can you install it for me?</summary>

Yes. Email <support@agentfire.com> with your pixel code, or your pixel ID from Events Manager.

</details>

<details>

<summary>Do you set up Meta's Conversions API?</summary>

No. AgentFire supports the Meta Pixel on your website, not a server-side Conversions API connection.

</details>
