Conversion Tracking

How to Set Up the Facebook (Meta) Pixel on Your Website

Install the Meta Pixel (Facebook Pixel) with Google Tag Manager: create it in Events Manager, add a Custom HTML tag, and verify with Meta Pixel Helper.

11 min read
Quick answer

Create a pixel in Meta Events Manager under Connect Data Sources > Web, copy the Pixel ID, then install it with a Google Tag Manager Custom HTML tag set to fire on All Pages. Verify it with the Meta Pixel Helper Chrome extension: a green checkmark with a PageView event means it's working.

By the end of this tutorial, you’ll have the Meta Pixel installed on your website, tracking visitor activity and ready to power your Facebook and Instagram ad campaigns. We’ll install it through Google Tag Manager, test it, and set up your first conversion event.

One naming note before we start. Meta renamed the Facebook Pixel to the Meta Pixel in 2022, and everyone still calls it the Facebook Pixel anyway. Same code, same job. We’ll use “Meta Pixel” here because that’s what the tools now say on screen.

What is the Meta Pixel (and why do you need it)?

The Meta Pixel is a small piece of code that tracks what people do on your website after they interact with your Facebook or Instagram ads.

In plain English: it connects your website to your Meta ad account. You see which ads lead to real actions (purchases, signups, page visits), and Meta can find more people like your best customers.

The pixel does three things for you:

  • Tracks conversions from ads. When someone clicks your ad and then buys or signs up, the pixel reports it back, so you know which campaigns pay for themselves. This is the Meta half of how conversion tracking works across your marketing.
  • Builds retargeting audiences. The pixel keeps a rolling list of your website visitors, so you can show ads to people who visited a pricing page but didn’t buy.
  • Feeds Meta’s ad delivery. The more conversion data the pixel sends, the better Meta’s algorithm gets at finding the right people for your ads.

Not sure what a pixel is in the first place? Start with our plain-English explainer on what a marketing pixel is, then come back here.

Before you start

You’ll need three things:

  • A Meta Business Suite account. This is the free business layer on top of your Facebook page, at business.facebook.com.
  • A Facebook ad account. Even if you’re not running ads yet, the pixel lives alongside one.
  • Google Tag Manager installed on your site. If it isn’t yet, follow our guide to install Google Tag Manager first. It takes about 15 minutes.

You can install the pixel without GTM (see the FAQ below), but this guide uses GTM because it’s cleaner to manage alongside your other tracking. New to GTM in general? The Google Tag Manager tutorial covers tags, triggers, and how the pieces fit.

Check your consent requirements

If your site gets visitors from the EU, UK, or other regions with consent laws, the pixel should fire only after a visitor accepts tracking cookies. A cookie consent banner integrated with GTM handles this for you. For the background, read how pixels and privacy rules interact.

Step 1: Create your Meta Pixel

First, create the pixel inside Meta’s Events Manager. Events Manager is the section of Meta Business Suite where all your tracking lives.

1

Open Events Manager

Go to business.facebook.com/events_manager2, or open Meta Business Suite and pick Events Manager from the All tools menu. Make sure the correct business account is selected in the top-left corner.

2

Connect a web data source

Click Connect Data Sources in the left sidebar, choose Web, then click Connect. You may see an extra confirmation screen asking you to pick Meta Pixel and click Connect again; Meta occasionally reshuffles these screens, but the flow is always Connect Data Sources, then Web, then create the pixel.

Events Manager Connect Data Sources Web

Newer accounts may label this a dataset instead of a pixel. That’s Meta’s current umbrella name for a source of event data. A web dataset and a pixel are the same thing for our purposes, and the ID works identically.

3

Name it and create it

Name your pixel after your website or business (for example, “Acme Co Website”), then click Create. If Meta asks how you want to connect your website, you can close that dialog or pick Do it yourself. We’ll handle the install in GTM.

Screenshot placeholder
Meta Events Manager › Connect Data Sources › Web
You should now see

a Pixel ID: a long number (usually 15 or 16 digits) shown at the top of your pixel’s page in Events Manager. Copy it somewhere handy. You’ll paste it into GTM in the next step.

Step 2: Install the pixel with Google Tag Manager

Now we’ll put the pixel’s base code on every page of your site using a GTM Custom HTML tag. A Custom HTML tag is GTM’s container for any script that GTM doesn’t have a built-in template for, and the Meta Pixel is the classic use case.

1

Create a new tag

In Google Tag Manager, open your container and click Tags in the left sidebar, then New. Name the tag “Meta Pixel - Base Code” so future you knows exactly what it is.

GTM Tags New
2

Choose Custom HTML and paste the code

Click the Tag Configuration box and choose Custom HTML. Paste in the Meta Pixel base code below, and replace both instances of YOUR_PIXEL_ID with the Pixel ID you copied in Step 1.

Meta Pixel base code
<script>
!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_PIXEL_ID');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=YOUR_PIXEL_ID&ev=PageView&noscript=1"
/></noscript>

The ID appears twice: once in the fbq('init', ...) line and once in the noscript image URL. Both need your real Pixel ID.

3

Set the trigger to All Pages

Click the Triggering box and choose All Pages. This tells GTM to load the pixel on every page of your site, which is exactly what the base code needs. Click Save.

Screenshot placeholder
GTM › Tags › Meta Pixel - Base Code › Custom HTML with All Pages trigger
You should now see

the tag “Meta Pixel - Base Code” listed in your GTM workspace with All Pages shown in its Firing Triggers column.

One pixel, one place

If your site already has the pixel code pasted into its theme or a plugin, remove it before publishing this tag. Running the pixel twice sends duplicate events, which inflates your numbers and confuses Meta’s reporting.

The base code only tracks PageView: someone loaded a page. Standard events tell Meta about specific actions with names it already understands, like ViewContent, AddToCart, Purchase, Lead, and CompleteRegistration.

Let’s add a Lead event that fires when someone lands on your thank-you page after submitting a form. This is the most common first conversion event for non-ecommerce sites.

1

Create a thank-you page trigger

In GTM, go to Triggers > New. Name it “Page View - Thank You Page”. Choose Page View as the trigger type, select Some Page Views, and set the condition to Page Path contains /thank-you (swap in your actual thank-you page path). Click Save.

2

Create the Lead event tag

Go to Tags > New and name it “Meta Pixel - Lead”. Choose Custom HTML again and paste this code:

Lead event
<script>
fbq('track', 'Lead');
</script>

For the trigger, pick the “Page View - Thank You Page” trigger you made a moment ago. Click Save.

This tag is short because it calls fbq, the function your base code tag creates. GTM doesn’t promise a firing order between tags on the same trigger, and if this tag fires before the base code, the event is lost. Open the Lead tag’s Advanced Settings > Tag Sequencing and set the Meta Pixel base code tag to fire before it.

You should now see

two Meta Pixel tags in your GTM workspace: the base code firing on All Pages, and the Lead event firing on the thank-you page.

Step 4: Test with Meta Pixel Helper

Before publishing, confirm the pixel actually fires. The Meta Pixel Helper is Meta’s free Chrome extension that shows which pixels are on any page you visit, though current versions ask you to sign in with a Facebook account. Search “Meta Pixel Helper” in the Chrome Web Store and confirm the developer listed is Meta before you install, because copycat extensions rank in the same results.

1

Open GTM Preview mode

In GTM, click Preview in the top right and enter your website URL. This opens your site in a new tab with your unpublished tags active, so you can test without pushing anything live.

2

Check the Pixel Helper

On your site’s tab, click the Meta Pixel Helper icon in your Chrome toolbar. A green checkmark with your Pixel ID and a PageView event means the base code is firing.

Screenshot placeholder
Chrome toolbar › Meta Pixel Helper popup on your site

Then visit your thank-you page directly and check again. The Helper should now also list a Lead event.

3

Confirm in Test Events

Back in Events Manager, open your pixel and click the Test Events tab. Enter your website URL and click Open Website. As you browse, events appear in the Test Events feed within a few seconds.

Screenshot placeholder
Meta Events Manager › your pixel › Test Events
You should now see

a green checkmark in the Pixel Helper, and your PageView (and Lead) events appearing in the Test Events feed.

Step 5: Publish your GTM changes

Everything so far lives in a GTM draft. Nothing reaches real visitors until you publish.

Click Submit in the top right of GTM, name the version “Added Meta Pixel”, and click Publish.

You should now see

a new version listed in your GTM container with that name. Your pixel is now live for every visitor.

Step 6: Verify in Events Manager

Give it a little traffic, then confirm real data is flowing.

Go to Events Manager and open your pixel. On the Overview tab, you should see PageView events counting up, and the pixel’s status showing Active. If you set up the Lead event, submit a test form on your live site and watch for it.

Screenshot placeholder
Meta Events Manager › your pixel › Overview

New events can take up to 20 minutes to show on the Overview tab, so don’t panic if it lags behind the Test Events feed. Once you see Active and events flowing, you’re done. This part matters: an installed pixel that nobody verified is one of the most common reasons ad accounts end up with empty conversion columns.

Common Meta Pixel events for marketers

Here are the standard events you’re most likely to use, and how to fire each one in GTM:

Standard eventWhen to use itTrigger in GTM
PageViewEvery page (automatic with base code)All Pages
ViewContentProduct pages, key content pagesSpecific page URLs
LeadForm submissionsThank-you page or form submission trigger
CompleteRegistrationAccount signupsRegistration confirmation page
AddToCartE-commerce add-to-cartButton click or custom event
PurchaseCompleted purchaseOrder confirmation page

Stick to these standard names instead of inventing your own. Meta builds its conversion reporting and audience tools around them, and a Purchase event does things a custom bought_stuff event never will.

Common problems and fixes

Pixel Helper shows “No Pixel Found.” This usually means the GTM tag isn’t firing. Check that your GTM container is published (not sitting in a draft), and that the pixel tag has the All Pages trigger attached. Use GTM Preview mode to watch the tag fire in real time.

The pixel fires but Events Manager says “No Activity Yet.” Events Manager can take up to 20 minutes to show new events. If it’s been longer, compare the Pixel ID in your GTM tag against the ID in Events Manager. A single wrong digit sends your data to a pixel that doesn’t exist.

Standard events aren’t tracking. If the base pixel works but your Lead or Purchase events don’t fire, the trigger is the usual suspect. The page URL condition must match what’s actually in the address bar, including trailing slashes and capitalization. “/thank-you/” and “/Thank-You” are different strings to GTM.

iOS 14 and ad blockers eat some of your data. A meaningful share of visitors use ad blockers or iOS tracking restrictions that stop the pixel from firing at all. This is normal, and every advertiser deals with it. When your ad spend grows, set up the Conversions API (Meta’s server-side tracking) as a supplement so more of your conversions get counted.

What to do next

Your pixel is live and reporting. From here:

  • Add more standard events from the table above as your site grows. Purchase and CompleteRegistration follow the same pattern as the Lead event.
  • Build a retargeting audience in Meta Ads Manager from your pixel’s website visitors. It fills up on its own from today forward.
  • Connect the rest of your tracking. The pixel covers Meta; for the full picture of ad clicks to revenue across every platform, read how conversion tracking works.

Frequently asked questions

What's the difference between the Meta Pixel and the Conversions API?
The Meta Pixel runs in the visitor's browser and sends events from there. The Conversions API sends the same events from your server instead, so ad blockers and browser privacy settings can't stop them. They aren't competitors: Meta recommends running both, with a shared event ID so duplicate events get merged. Most sites start with the pixel, then add the Conversions API once ad spend justifies the extra setup.
Do I need the Meta Pixel if I'm not running Facebook ads?
Not for day-to-day analytics, but install it anyway if you might run Facebook or Instagram ads within the next 6 months. The pixel builds retargeting audiences from your website visitors over time. Most website audiences can include visitors from up to the past 180 days, and audiences built on Purchase events can reach back up to 730 days. Install the pixel today and you'll launch your first campaign with a warm audience already built instead of starting from zero.
Will the Meta Pixel work with iOS 14+ privacy changes?
Yes, but expect gaps. Since Apple's App Tracking Transparency rolled out in 2021, iPhone users who decline tracking send Meta far less data, so your pixel will undercount iOS visitors and conversions. The pixel is still worth installing: it captures everyone else, and Meta models some of the missing data. For fuller coverage, supplement the pixel with the Conversions API.
Can I install the Meta Pixel without Google Tag Manager?
Yes. You can paste the pixel base code directly into the head section of every page, or use a partner integration: Events Manager has built-in setup flows for WordPress, Shopify, Squarespace, Wix, and other platforms. We recommend Google Tag Manager because it keeps the pixel alongside your other tracking, and you can add or edit events without touching your site's code.
How long does it take for the Meta Pixel to start collecting data?
Almost immediately. Events show up in the Test Events tab of Events Manager within seconds of a page load. The main Events Manager overview is slower: allow up to 20 minutes for new events to appear there, and up to a day for the pixel's status to settle on Active. If nothing appears after 20 minutes, check that your GTM container is published.

Keep learning