How to Add Meta Pixel to WordPress: Plugin, Manual Code or GTM, Plus Conversions API
A comparison of the three ways to put the Meta Pixel on a WordPress site, what each one gives you for events and the Conversions API, and how to avoid duplicate pixels, caching plugins that delay it and untested setups.
In short
There are three ways to add the Meta Pixel to WordPress: Meta's free plugin, Meta pixel for WordPress, which also sends Conversions API events; the base code pasted into every page's head via a child theme or header code plugin; or a Google Tag Manager tag. Load the base code through one route only, or events can count twice.
There are three ways to add the Meta Pixel to a WordPress site: install Meta's own plugin, paste the pixel base code into the head of every page, or load it through Google Tag Manager. They differ in which events you get without extra work, whether the Conversions API comes with them, and how easily you end up with two pixels on one page. It assumes you already have a dataset (the pixel's container in Events Manager) and its ID. If not, start with our Meta Pixel setup guide.
The three routes compared
| Route | Effort | Events and Conversions API | Duplicate risk |
|---|---|---|---|
| Meta pixel for WordPress plugin | Low: install and connect your Meta account | PageView on every page, Lead from several form plugins, shop events from WooCommerce and Easy Digital Downloads; Conversions API included | High if a theme field, an older pixel plugin or a tag manager also loads the pixel |
| Manual code in the head | Low to medium: one paste, but every extra event is code you write | PageView only until you add event calls yourself; no Conversions API | Medium: easy to forget when you later add a plugin |
| Google Tag Manager | Medium: needs Tag Manager on the site and some trigger setup | Any click, form or page event you can build a trigger for; no Conversions API from the web container | High if the base code is also hard-coded or installed by a plugin |
Route 1: Meta's official WordPress plugin
Meta's plugin is listed on WordPress.org as Meta pixel for WordPress, by the author Facebook (it was previously called Facebook for WordPress, and its address still ends in official-facebook-pixel). At the time of writing it is at version 5.2.2, released on 23 July 2026, with more than 400,000 active installations, and it requires WordPress 5.7 and PHP 7.4 or later. Its description says it installs the pixel to capture actions such as Lead, ViewContent, AddToCart, InitiateCheckout and Purchase, and that it includes support for the Conversions API, which sends events from your site's server as well as the browser.
- 1In the WordPress dashboard, go to Plugins, click Add New, search for Meta pixel for WordPress and install the one whose author is Facebook.
- 2Activate it, then open Settings and choose Meta. The page is titled Meta Pixel Settings.
- 3Start the connection, log in through Facebook Login for Business (used since version 5.1.0; older setups see an Upgrade Now notice) and choose the business and the dataset (pixel) your ad account uses.
- 4The connection gives your site an access token. The plugin uses it for its Conversions API features.
- 5Clear your caching plugin's cache so visitors receive pages with the new code.
The plugin prints the base code and a PageView call through WordPress's wp_head hook, which outputs scripts in the head. Its code also contains integrations for Contact Form 7, WPForms, Ninja Forms, Formidable Forms, Mailchimp for WordPress, Easy Digital Downloads and WooCommerce. The Contact Form 7 integration, for example, sends a Lead event when a form is submitted and fills in email, phone and name from the form's fields. Its WordPress.org rating is about 2.7 out of 5 at the time of writing, and recent support threads report fatal errors and consent tool conflicts, so test it. Shops should read our guide to WooCommerce server-side tracking first, which covers Meta for WooCommerce, the separate extension built for stores. Run one Meta plugin, not both.
Route 2: add the pixel code without a plugin
Meta's developer documentation recommends placing the base code between the opening and closing head tags on every page you want to track, because it runs sooner there and is less likely to be blocked by the browser or other code. It also asks you to leave the PageView call in the base code intact. On WordPress you have two practical places to put it.
- A child theme. Add a small function to the child theme's functions.php that prints the base code on the wp_head hook. Do not edit the parent theme: WordPress's theme handbook warns that changes to a parent theme disappear the next time it updates.
- A header code plugin. WPCode (Insert Headers and Footers) lets you paste the code into a header field without touching theme files, and its listing names inserting Facebook pixel code as one of its uses.
What you get is PageView on every page and nothing else. Any Lead or Purchase event needs an fbq('track') call that you or a developer add to the right page or form, and there is no server side at all. It suits brochure sites that only need audiences and URL-based custom conversions, such as any page containing /thank-you.
Route 3: Google Tag Manager
Meta says the pixel works in most tag management solutions, though it still recommends direct installation. Tag Manager suits sites that already run GA4 or Google Ads through it, or that need click and form events without editing code. Site Kit by Google can add Tag Manager to WordPress without code. Inside Tag Manager, put the base code in a Custom HTML tag with an All Pages trigger, add event tags that fire after it, and publish the container. The web container only sends browser events. The Conversions API needs something on a server, such as a server-side container or a separate service.
How a second pixel sneaks in, and how to find it
The usual combinations are a theme option such as a header scripts box that someone filled in years ago, an older third-party pixel plugin left active, Meta's plugin plus a Tag Manager tag, or Meta's WordPress plugin plus Meta for WooCommerce. When the same ID is loaded twice, each event can be reported twice. When two different IDs are loaded, Meta's advanced documentation warns that a plain track call goes to every initialised pixel and can over-fire.
- View the page source and search for fbq('init' and fbevents.js. More than one init call for your ID means two installs.
- Open the browser's developer tools, choose the Network tab, filter by facebook.com/tr and reload. Two PageView requests for one page load is a duplicate.
- Install Meta Ads Data Advisor (formerly Meta Pixel Helper), Meta's extension for Chrome and Edge. It lists the pixels it finds and treats duplicate pixel code as a setup error.
- Run the page through our pixel inspector, which lists pixels hard-coded in the initial HTML. It cannot see tags that Tag Manager injects later, so check the container as well.
Remove the second copy at its source: empty the theme field, deactivate the old plugin or pause the tag. If the pixel shows no activity at all, our guide to a Meta Pixel that is not firing works through the causes.
Caching, script delay and consent banners
Speed plugins are the most common reason a correctly installed pixel under-reports on WordPress. WP Rocket's Delay JavaScript execution option, on its File Optimization tab, holds back all JavaScript, inline scripts included, until the visitor moves the mouse, touches the screen, scrolls or presses a key. A visitor who reads the page without doing any of those never sends a PageView. To exempt the pixel, add keywords from its code to the Excluded JavaScript Files box, such as fbevents.js (the file the base code loads) and fbq (the function it calls), plus facebook_signal.js with Meta's plugin, or add the nowprocket attribute to the script tag. WP Rocket documents the keyword method but names no pixel keywords, so confirm events arrive afterwards. Other optimisation plugins have similar delay settings. Then clear the page cache, because cached pages keep serving the old HTML.
Consent banners delay the pixel on purpose. Where the banner blocks marketing tags until a visitor accepts, as is common in the EEA and the UK, a test with the banner unanswered correctly shows nothing. Make sure the banner actually controls whichever route you used: a pixel hard-coded in the theme ignores a banner that only manages Tag Manager tags, and Meta's plugin has no consent setting on its settings page and fires on page load by default, so your banner must block it. Our guide to holding the Meta Pixel until consent shows both methods.
Conversions API on a WordPress site without a shop
For a lead generation site, the event that matters is usually Lead, sent when a form is submitted. The Conversions API lets your server send it to Meta directly, so it arrives even when the browser blocks the pixel. Meta's server event documentation lists event_name, event_time, action_source and user_data as required, notes that event_source_url is required for website events, and rejects events whose event_time is more than seven days old. The event_id field is marked optional, but Meta recommends it for deduplication.
That recommendation is the whole trick. If the browser sends fbq('track', 'Lead', {}, {eventID: 'lead-4821'}) and the server sends a Lead with event_id lead-4821, Meta counts one lead, provided both arrive within 48 hours. Without a shared ID, leads can be counted twice. Our explainer on event_id deduplication covers the details, and whichever tool sends your server events should support it. EndFrame, for example, has no WordPress plugin: you add its snippet like any other script, and it forwards conversions to the Meta Conversions API, but Meta only keeps one copy when the site passes the same event name and event_id to the pixel and to endframe.track.
Test before you trust it
- 1Turn off your ad blocker, or use a clean browser profile, because blockers stop the pixel and the testing tools with it.
- 2In Events Manager, open Data sources, select your dataset and open Test events, then use its option to test browser events on your website.
- 3Load a few pages and submit a real form. Each page should show one PageView and the form one Lead.
- 4If you send server events, include the test_event_code shown in Test events while testing, confirm the server Lead appears next to the browser one, then remove the code, as Meta says it is for testing only.
- 5Repeat after any plugin, theme or cache change.
Our guide to testing Meta Pixel and Conversions API events explains how to read the results, including how to tell a deduplicated pair from a double count.
Frequently asked questions
Can I use the Meta plugin and Google Tag Manager at the same time?
Only if they do different jobs. If the plugin installs the base code and a tag in Google Tag Manager also loads it, every page view is sent twice. If you want Tag Manager for click and form events, let one of the two own the base code and the PageView, and make sure the other never initialises the pixel a second time.
Where do I find the Meta plugin's settings after activating it?
The plugin adds a page under the Settings menu of the WordPress dashboard, labelled Meta, with the page title Meta Pixel Settings. From there you start the connection, which now uses Facebook Login for Business. If the connection fails or the settings page stays blank, search the plugin's support forum on WordPress.org, where users report problems like these and the fixes that worked.
Does the WordPress plugin work for a site with no shop?
Yes. Besides page views, its source code includes integrations that send a Lead event when a visitor submits a form built with Contact Form 7, WPForms, Ninja Forms, Formidable Forms or Mailchimp for WordPress. For other form plugins you would add the event yourself or through a tag manager.
Do I still need the pixel if I send events through the Conversions API?
Keep both. Meta's plugin description says the Conversions API alongside the pixel creates a more reliable connection: the pixel reports what happens in the browser, while server events still arrive when a browser blocks the pixel. Running both is only safe when each pair of events shares the same event name and ID, so that Meta can remove the duplicate.
Sources
- 1.Meta pixel for WordPress - WordPress.org
- 2.Get started with the Meta Pixel - Meta for Developers
- 3.Server Event Parameters - Meta for Developers
- 4.Handling Duplicate Pixel and Conversions API Events - Meta for Developers
- 5.Delay JavaScript execution - WP Rocket Knowledge Base
- 6.Facebook-Pixel-for-WordPress - GitHub
Try EndFrame
Add a server-side path for your conversions.
EndFrame collects events first-party and forwards conversions server-side to Meta, GA4, TikTok, and webhooks with event-ID deduplication — then credits each conversion to its campaign, with the visit-to-conversion path you can audit.
No credit card required