Accurate tracking is the backbone of any successful Facebook Ads campaign. Without it, you're flying blind โ€” wasting budget on audiences that don't convert and missing opportunities to optimize.

In this guide, I'll walk you through setting up Facebook Pixel and Conversion API (CAPI) the right way. No fluff, just a technical implementation that actually works.

What You'll Need

Step 1: Create Your Pixel

Go to Events Manager โ†’ Connect Data Sources โ†’ Web โ†’ Facebook Pixel. Give it a name (e.g., "Main Pixel") and enter your website URL. Click Create.

Copy the Pixel ID โ€” you'll need it for the next step.

Step 2: Install the Base Pixel Code

Add the following code to the <head> of every page on your website, immediately after the opening <head> tag:

<!-- Facebook Pixel --> <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>

Replace YOUR_PIXEL_ID with your actual Pixel ID.

Step 3: Configure Standard Events

Add event tracking to key actions. Here are the most important ones for e-commerce:

ViewContent

Fire this on product pages or landing pages:

fbq('track', 'ViewContent', { content_name: 'Product Name', content_category: 'Category', content_ids: ['SKU-123'], content_type: 'product', value: 49.99, currency: 'USD' });

AddToCart

Fire when a user adds an item to the cart:

fbq('track', 'AddToCart', { content_name: 'Product Name', content_category: 'Category', content_ids: ['SKU-123'], content_type: 'product', value: 49.99, currency: 'USD' });

Purchase

Fire on the order confirmation page:

fbq('track', 'Purchase', { value: 149.97, currency: 'USD', content_ids: ['SKU-123', 'SKU-456'], content_type: 'product', num_items: 3 });

Step 4: Set Up Conversion API (CAPI)

CAPI sends data directly from your server to Facebook, bypassing browser limitations like iOS 14+ tracking restrictions. This improves data reliability.

There are two ways to implement CAPI:

If you're using Shopify, simply enable the Facebook & Instagram Sales Channel โ€” it automatically sets up CAPI for you.

Step 5: Verify Your Setup

Use the Facebook Pixel Helper Chrome extension to check if events are firing correctly. In Events Manager, you should see "Active" status within minutes.

Common Mistakes to Avoid

Final Thoughts

A properly configured Pixel + CAPI setup is the foundation of measurable Facebook Ads performance. It allows you to optimize campaigns based on real data and retarget audiences with precision.

Need help implementing this on your site? I offer Pixel & CAPI setup services โ€” get in touch and I'll handle the technical work so you can focus on scaling.

Need help with Pixel & CAPI setup?

I'll install everything for you โ€” from Pixel events to CAPI โ€” so you can start tracking accurately right away.

Get Started โ†’

โ† Back to Blog