WordPress connected to Meta through the Conversions API

Meta Pixel on WordPress: Setup, Events and Conversions API

If you run ads on Facebook or Instagram, the Meta Pixel tells Meta which visits turn into leads or sales. That data improves your ad delivery and your reports. Here is how to add it to WordPress with Google Tag Manager or native code, and where the Conversions API fits.

Pixel and Conversions API in one minute

  • The Meta Pixel runs in the visitor’s browser. Ad blockers and privacy settings can stop it.
  • The Conversions API sends the same events from your server, so fewer of them are lost.
  • When you use both, Meta deduplicates them: the Pixel’s eventID must match the server’s event_id, and the event names must match too.

Step 1: get your Pixel ID

In Meta Events Manager, create or select your data source and copy its ID.

Step 2: install the base code

With Google Tag Manager, create a Custom HTML tag with Meta’s base code and an All Pages trigger. Without Tag Manager, print the same code in wp_head from your child theme.

<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>

Step 3: track leads

Reuse the Contact Form 7 data layer event from the GA4 conversion guide. In Tag Manager, add a Custom HTML tag with the cf7_submit_success trigger:

<script>
fbq( 'track', 'Lead', {}, { eventID: 'lead-' + Date.now() } );
</script>

Other standard events you may need: Contact, CompleteRegistration, and Purchase for online stores, with value and currency.

Step 4: add the Conversions API

The Conversions API runs on a server, not in the browser. The common options are:

  • A server-side Tag Manager container.
  • Meta’s Conversions API Gateway.
  • Custom code that sends events to Meta’s Graph API.

Whatever you choose, send the same event name and the same event ID as the Pixel. Customer information such as emails or phone numbers must be hashed with SHA-256 before it is sent.

Step 5: test it

  • In Events Manager, open Test events and browse your site.
  • Install the Meta Pixel Helper extension for Chrome to see what fires on each page.
  • After adding the Conversions API, check that matching events show as deduplicated.

Common mistakes

  • Installing the Pixel with a plugin and Tag Manager at the same time.
  • Firing Lead on a button click instead of on a sent form.
  • Sending server events without an event ID, so they can’t be deduplicated.
  • Testing with an ad blocker turned on.
  • Firing the Pixel before the visitor gives consent where the law requires it.

To measure the same leads in Google Analytics, read how to track Contact Form 7 submissions in GA4.

If you want me to set up the Meta Pixel on your site, get in touch. You can also browse my portfolio or read more about me.

Scroll to Top