Overview
Facebook Pixel is essential for tracking conversions from your Facebook and Instagram ad campaigns. For WooCommerce stores, proper pixel integration enables:
- Conversion tracking (purchases, add-to-cart, etc.)
- Audience building (remarketing to website visitors)
- Lookalike audience creation
- Conversion-optimized bidding (oCPM)
- Dynamic product ads (retargeting with specific products)
Step 1: Create the Facebook Pixel
You need a Facebook Business Manager account to create a pixel:
- Go to business.facebook.com → Events Manager
- Click "Connect Data Source" → "Web" → "Facebook Pixel"
- Name your pixel (e.g., "StoreName — Main Pixel")
- Enter your website URL
- Click "Continue" — you'll receive your Pixel ID (a 15-16 digit number)
Save your Pixel ID — you'll need it for the installation steps below.
Step 2: Install the Base Pixel Code
You have three options for installing the base pixel code on WooCommerce:
Option A: Using a Plugin (Recommended)
The easiest method for non-developers:
- Install the "PixelYourSite" or "Facebook for WooCommerce" plugin
- Go to the plugin settings
- Enter your Facebook Pixel ID
- The plugin automatically installs the base code and fires standard events on all pages
Option B: Manual Code Installation
For full control over what fires where:
- In WordPress admin, go to Appearance → Theme Editor
- Open
header.php(or use a header injection plugin) - Paste the Facebook Pixel base code right after the
<head>tag:
<!-- Meta Pixel 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>
<!-- End Meta Pixel Code -->
Option C: Google Tag Manager
If you already use GTM, add the pixel as a custom HTML tag with an "All Pages" trigger. This gives you centralized tag management.
Step 3: Set Up Standard Events
For WooCommerce, the most important standard events are:
| Event | When to Fire | Key Parameters |
|---|---|---|
ViewContent | Product detail page | content_ids, content_type, value, currency |
AddToCart | When item added to cart | content_ids, content_type, value, currency |
InitiateCheckout | Checkout page load | content_ids, num_items, value, currency |
Purchase | Order confirmation page | content_ids, content_type, value, currency |
Purchase Event Code (for order confirmation page)
<script>
fbq('track', 'Purchase', {
content_ids: ['product_1', 'product_2'], // Product IDs
content_type: 'product',
value: 99.50, // Total order value
currency: 'USD'
});
</script>
Pro Tip: The Purchase event with value and currency is the most critical — it powers conversion-optimized bidding and ROAS reporting. Make sure the value matches the actual order total including shipping and tax.
Step 4: Enable Advanced Matching (Optional but Recommended)
Advanced Matching sends hashed customer data (email, phone, name) with pixel events, improving match rates for custom and lookalike audiences:
fbq('init', 'YOUR_PIXEL_ID', {
em: 'hashed_email', // SHA-256 hashed email
ph: 'hashed_phone', // SHA-256 hashed phone
fn: 'hashed_first_name', // SHA-256 hashed first name
ln: 'hashed_last_name' // SHA-256 hashed last name
});
Step 5: Verify with Pixel Helper
- Install the Meta Pixel Helper Chrome extension
- Navigate to your WooCommerce store
- Visit each key page: product page, cart, checkout, order confirmation
- Click the Pixel Helper icon to verify each event fires correctly
- Check that event parameters (especially value and currency) are populated
Step 6: Set Up Conversions API (CAPI)
The Conversions API supplements the pixel by sending data server-side, improving data reliability (especially with iOS privacy restrictions and ad blockers):
- Use the "Facebook for WooCommerce" plugin — it includes CAPI integration
- Or implement via the Conversions API directly
- Pair the pixel (client-side) with CAPI (server-side) for maximum data quality
Troubleshooting
- Pixel not firing: Check that the pixel ID is correct and the code is in the
<head>section. Clear cache plugins. - Purchase event not firing: Ensure the code is on the Thank You / order confirmation page only. In WooCommerce, this is typically
thankyou.phpor the order-received endpoint. - Value showing as 0: Make sure you're passing the dynamic order total, not a hardcoded value.
- Duplicate events: If using both a plugin and manual code, you'll get double-firing. Choose one method only.
Conclusion
Proper Facebook Pixel integration on WooCommerce unlocks the full power of Meta advertising — from conversion tracking to audience building to dynamic product ads. Use the "Facebook for WooCommerce" plugin for the quickest setup, or implement manually for maximum control. Don't forget to add the Conversions API for maximum data reliability in the post-iOS 14.5 era.