A Facebook Pixel (now called the Meta Pixel) is a small piece of tracking code you place on your website. It lets you see which visitors came from your Facebook or Instagram ads, measure what they did on your site, and build audiences to retarget later. If you're running or planning to run ads on Facebook or Instagram for your business, adding the pixel is one of the first things you should do.
What You Need Before You Start
- A Meta Business Suite (Business Manager) account connected to your Facebook Page.
- Access to edit your website's files, or admin access to your WordPress dashboard.
Step 1: Get Your Pixel Code from Meta
- Log in to Meta Business Suite and open Events Manager.
- Click Connect Data Sources, choose Web, then select Meta Pixel.
- Give your pixel a name, usually your business name, and enter your website address.
- On the next screen, choose Install code manually and copy the full pixel code shown. It starts with a line referencing fbevents.js.
Keep this code handy. You'll also see your unique Pixel ID, a string of numbers, which some WordPress plugins ask for instead of the full code.
Step 2: Add the Pixel to Your Website
If Your Website Runs on WordPress
The easiest way is through a plugin rather than editing theme files directly, since a theme update can wipe out manual edits.
- From your WordPress dashboard, go to Plugins > Add New.
- Search for a header and footer script plugin, for example a plugin called Insert Headers and Footers or PixelYourSite, and click Install Now, then Activate.
- Open the plugin's settings and paste the full pixel code into the Header section.
- Click Save.
If your theme already has a built-in "Header Scripts" or "Custom Code" field under Appearance > Theme Settings, you can paste the code there instead of installing a plugin.
If Your Website Is Not WordPress
For a custom-built or static HTML site, you'll add the code directly to your page files.
- Open your website's files using File Manager in your hosting control panel, or connect via FTP.
- Open the main template file that's shared across all pages, often called header.php or header.html.
- Paste the pixel code just before the closing </head> tag.
- Save the file and repeat for any other template files not sharing that header, so the pixel loads on every page.
If you're not comfortable editing code directly, ask whoever manages your website design to add the snippet for you. One misplaced character in a template file can break the whole page.
Step 3: Verify the Pixel Is Working
- Install the Meta Pixel Helper browser extension, available for Chrome.
- Visit your website using that browser.
- Click the Meta Pixel Helper icon. A green checkmark and your pixel name confirm it's firing correctly.
If the extension shows no pixel detected, check your site's page source for the text "fbevents" to confirm the code is actually on the live page, and make sure no ad blocker is interfering with your own test.
A Note on Privacy and Consent
Because the pixel tracks visitor behavior, it's good practice to disclose this in your site's privacy policy and, where relevant, through a cookie consent notice. See How to Add a Privacy Policy and Cookie Consent Notice to Your Website if you haven't set one up yet.