How many of the people who clicked your Facebook or Instagram ad then filled in a form or bought something on your site? The Meta Pixel is a small piece of JavaScript you add to your website, and it is the foundation for answering that: it reports what visitors do on your site back to Meta. A correct Meta Pixel setup lets you measure ads by results rather than clicks.

This guide follows the order in Meta’s developer documentation: add the base code, send standard events, manage cookie consent and verify the install. It is not legal advice; check the rules that apply to you on consent and privacy.

1. Where do you get the Pixel base code?

You create the Pixel in Meta Events Manager, and the base code lives there too. Meta’s documentation points you to Ads Manager > Events Manager for the base code (Meta for Developers: Get started with the Meta Pixel). If you are creating a Pixel for the first time, Meta’s help page walks through it: Meta Business Help Centre: Set up and install the Meta Pixel.

Menus change from time to time; if yours look different, Meta’s current documentation wins.

2. Add the base code to your site’s <head>

Meta recommends adding the base code between the opening and closing <head> tags of every page where you want to track visitor actions. Most developers put it in the persistent header template so it runs on all pages. Replace {your-pixel-id-goes-here} with your Pixel ID in two places: the fbq('init', …) line and the address inside <noscript>.

The two key lines of the code are:

fbq('init', 'YOUR_PIXEL_ID');
fbq('track', 'PageView');

The documentation asks you to leave the automatic PageView call intact, because that line reports page views. Copy the full code from Events Manager rather than from this article, as Meta may update it.

You do not have to paste code by hand if your site runs on a ready-made system: Meta says the Pixel works in most tag management solutions. If you have a separate mobile site, add the Pixel to both. An <img> tag install exists but the documentation does not recommend it.

3. Send standard events

PageView only says a page opened. To measure ad results you also need to report valuable actions. Meta defines ready-made standard events for this; you call fbq('track') with an event name and an optional parameter object (Meta for Developers: Conversion tracking).

The events most useful to service businesses, per Meta’s standard events reference:

Event Meta’s description
Lead A sign-up is completed
Contact A person contacts the business by phone, SMS, email, chat, etc.
Schedule A person books an appointment to visit a location
Purchase A purchase or checkout is completed
ViewContent A person visits a page, such as a product or landing page

Purchase requires both currency and value. For Lead, CompleteRegistration, StartTrial and Subscribe they are optional. Example:

fbq('track', 'Purchase', {value: 49.99, currency: 'USD'});

Where do you put the event?

According to the documentation you can call fbq('track') anywhere between your page’s opening and closing <body> tags, either when the page loads or when a visitor acts. Two common patterns:

  • Thank-you page: if visitors land on a separate page after submitting a form, add fbq('track', 'Lead'); to that page’s <body>.
  • Button click: if there is no separate page, attach the same call to the button’s click handler. The documentation example uses jQuery but says you can trigger it any way you like.

The base code must already be installed on every page where you track events; the event code does not work on its own.

Visitor data goes to Meta, so plan consent during setup. Meta’s consent documentation offers two calls to pause and resume Pixel firing (Meta for Developers: GDPR and consent):

fbq('consent', 'revoke');   // BEFORE init
fbq('init', 'YOUR_PIXEL_ID');
fbq('track', 'PageView');

// Once the visitor has given affirmative consent:
fbq('consent', 'grant');

The documentation is explicit on two points: call revoke before init, and call it on every page. You can collect consent through a cookie banner (for example an “I agree” action); if your tag manager already handles consent, this code may not be needed.

Meta also states that each company is responsible for its own compliance with the laws that apply to it. Make sure your privacy and cookie notices cover this data transfer.

5. Check that the Pixel works

The verification steps in Meta’s documentation are simple:

  1. Open a page that has the Pixel; this fires fbq('track', 'PageView').
  2. In Events Manager, find your Pixel and open its details.
  3. If you see a new PageView event, the Pixel is installed.
  4. If not, wait a few minutes and refresh the page.

If it still does not work, Meta recommends the Meta Ads Data Advisor Chrome extension for debugging; it was formerly called Meta Pixel Helper. Per Meta’s extension documentation, a badge on the icon shows how many Pixel events fired on the current page, and no badge means no Pixel on the page. The side panel shows Pixel status as Active, Warning or Inactive; an event Error means a critical configuration issue such as blocked parameters or duplicate events. A Pixel can show a warning even while events are being sent, so open the Pixel for detail (Meta for Developers: Meta Pixel Helper).

To test, submit a form on your own site and confirm the Lead event appears in both the extension and Events Manager.

Server-side tracking with the Conversions API

The Pixel sends data from the browser. Meta’s Conversions API connects the same kind of data from your server, app or CRM to Meta, and server events are processed like Pixel events. For websites that already have a Pixel, it can be set up for website events in one click from Events Manager, with no code (Meta for Developers: Conversions API). If you use both, pass an eventID as the fourth parameter of the event call so Meta can deduplicate Pixel and server events (see the events reference).

Short checklist

  • Pixel created in Events Manager, ID noted
  • Base code in every page’s <head>, ID correct in both places
  • PageView line left in place
  • A standard event (such as Lead) fires for the valuable action
  • Consent: revoke before init, grant after consent
  • Test event seen in Events Manager and the Data Advisor

Once the Pixel is in place, your ad reports can answer “how many people filled in the form” instead of “how many clicks”. For the Google equivalent, see Google Ads conversion tracking setup, and for what we cover, the digital advertising service page.

Have a project in mind?

Tell me what you need in a few sentences. I reply within two working days and, if needed, we can set up a short call.

Get a quote