How to install the Meta pixel and Google tag on WordPress

On WordPress, paste the snippet Madder gives you into a header plugin (or the official Meta plugin), fire Lead on your thank-you page, and clear the cache.

For WordPress. Takes about 15 minutes

On this page

Before you start#

  • An Administrator login to WordPress (plugins need it).
  • The code from Madder’s pixel window (Copy code), already carrying your pixel ID (where it comes from).
  • Know which form plugin you use and where it lands people after a submission.

1Choose plugin or theme header#

Use one of these two options and never both, since two copies of the pixel count every visit twice. Menu paths are as of September 2026.

Option A, a header plugin (recommended)
Go to Plugins › Add New Plugin, search “WPCode”, Install Now, Activate. Then Code Snippets › Header & Footer, paste the snippet into the Header box, Save Changes. This survives theme updates.
Option B, the official plugin
Install “Meta pixel for WordPress”. Open its settings page, click Get Started, and sign in; the connection flow lets you pick the existing pixel (use the ID from Madder’s pixel window, not a new one). It also turns on the Conversions API. Do not also paste the snippet.

Avoid editing header.php in the Theme File Editor (under Appearance, or Tools on block themes): WordPress warns it keeps no backup and a theme update wipes the change.

2Fire the Lead event#

Send people to a dedicated thank-you page after the form, then fire Lead only there:

  1. Set your form plugin to redirect to /thank-you after a submission (WPForms, Gravity Forms and Ninja Forms can; Contact Form 7 cannot, so use its event below).
  2. In WPCode go to Code Snippets › Add Snippet › Add Your Custom Code (New Snippet), type HTML Snippet, paste:
<script>fbq('track', 'Lead');</script>
  1. Under Insertion choose Auto Insert, location Site Wide Header, then in Smart Conditional Logic restrict to page URL contains /thank-you. Activate and Save Snippet.

If your form shows an inline success message instead, use the plugin’s success event (Contact Form 7 emits wpcf7mailsent) to call fbq('track', 'Lead').

3The Google tag#

Paste the Google tag into the same WPCode Header box, below the Meta snippet. Which tag and which conversion action: Install the Google tag on your website.

4Clear the cache and verify#

  1. If you run WP Rocket, W3 Total Cache, LiteSpeed Cache, WP Super Cache or a host cache, purge it now; cached pages keep serving the old header.
  2. Install the Meta Pixel Helper Chrome extension (now listed as Meta Ads Data Advisor). Load any page: one pixel, status “Active”, your ID. Submit the form: Lead appears on the thank-you page.
  3. In Meta Events Manager: Data sources › your pixel › Test events, enter your URL, submit the form, and check that PageView and Lead appear.
  4. In Madder, open the pixel window again with Set up tracking. Madder checks as it opens. “The pixel is live.” means you are done. Otherwise press Check again after a minute, and if Madder still can’t see it, press Mark as installed.

If it doesn’t work#

Pixel Helper sees nothing
Purge the page cache, and check that the snippet shows “Active” in WPCode.
Two pixels, or PageView fires twice
The snippet is in WPCode and the Meta plugin (or theme header); keep one.
Lead fires on every page
The conditional logic is missing; restrict to the thank-you URL.
Lead fires but the pixel ID differs
The Meta plugin created a new pixel; reconnect using Madder’s ID.
Cookie banner installed
The pixel loads only after consent; test after accepting.