Facebook

Facebook Pixel: What It Is & How to Set It Up (2026 Guide)

SocialRails Team
SocialRails Team
8 min read

TL;DR - Quick Answer

15 min read

Comprehensive guide with practical insights you can apply today.

Quick answer: The Facebook Pixel (now called Meta Pixel) is a snippet of JavaScript code you add to your website. It tracks visitor actions (page views, purchases, sign-ups) and sends that data to Facebook so you can run targeted ads, build retargeting audiences, and measure ad performance.

Create content, post everywhere

Create posts, images, and carousels with AI. Schedule to 9 platforms in seconds.

Start your free trial

What Is the Facebook Pixel?

The Facebook Pixel (officially renamed Meta Pixel) is a small piece of tracking code that connects your website to your Facebook Ads account. When someone visits your site after clicking a Facebook ad, or even just visiting organically, the Pixel records what they do.

What it tracks:

  • Page views
  • Add to cart actions
  • Purchases and their value
  • Form submissions (leads)
  • Content views
  • Searches on your site
  • Custom events you define

What you can do with that data:

  • Retarget website visitors with ads (show ads to people who visited but didn't buy)
  • Track conversions from Facebook ads (know exactly which ads drive sales)
  • Optimize ad delivery (Facebook shows your ads to people most likely to convert)
  • Build lookalike audiences (find new customers similar to your best existing ones — see our Facebook lookalike audience guide)
  • Measure ROAS (return on ad spend — understand Facebook advertising costs before you start)

How to Create a Facebook Pixel

Step 1: Go to Events Manager

  1. Open Facebook Business Manager (business.facebook.com)
  2. Click Events Manager in the left menu
  3. Click "Connect Data Sources"
  4. Select "Web"
  5. Click "Connect"

Step 2: Name Your Pixel

  • Give it a name (usually your business name)
  • Enter your website URL
  • Click "Continue"

Step 3: Get Your Pixel Code

Facebook gives you a Pixel ID (a number like 123456789012345) and a base code snippet.

The base code looks like this:

<!-- 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>
<!-- End Meta Pixel Code -->

Replace YOUR_PIXEL_ID with your actual Pixel ID.


How to Install the Facebook Pixel

Method 1: Manual Installation

Paste the Pixel code in the <head> section of every page on your website:

  1. Copy the base code from Events Manager
  2. Open your website's HTML
  3. Paste the code between <head> and </head>
  4. Save and publish

Method 2: Google Tag Manager

  1. Open Google Tag Manager
  2. Create a new Tag, select "Custom HTML"
  3. Paste the Facebook Pixel code
  4. Set the trigger to "All Pages"
  5. Save and publish

Method 3: Platform-Specific Installation

PlatformHow
ShopifySettings → Online Store → Preferences → paste Pixel ID
WordPressUse the "Meta Pixel" plugin or add to header via theme settings
WixMarketing Integrations → Facebook Pixel → paste ID
SquarespaceSettings → Advanced → Code Injection → paste in Header
BigCommerceStorefront → Script Manager → add Pixel code
WebflowProject Settings → Custom Code → Head Code

Method 4: Conversions API (Server-Side)

For more reliable tracking (not blocked by ad blockers):

  1. In Events Manager → Settings → "Conversions API"
  2. Set up server-side event tracking
  3. Works alongside the browser Pixel for redundancy
  4. Requires developer setup or a partner integration

Recommendation: Use both the browser Pixel AND Conversions API for maximum data accuracy. The Conversions API captures events that ad blockers may prevent the browser Pixel from seeing.

Quick Knowledge Check
Test your understanding

You've installed the Facebook Pixel via Google Tag Manager. Which trigger should you use so the base PageView event fires everywhere?

💡
Hint: Think about when and where the base Pixel code needs to run.

Facebook Pixel Standard Events

Standard events are predefined actions Facebook recognizes:

EventCodeWhen to Use
PageViewfbq('track', 'PageView')Every page load (already in base code)
ViewContentfbq('track', 'ViewContent')Product page, blog post, key content
AddToCartfbq('track', 'AddToCart')Item added to shopping cart
InitiateCheckoutfbq('track', 'InitiateCheckout')Checkout process started
Purchasefbq('track', 'Purchase', {value: 29.99, currency: 'USD'})Completed purchase
Leadfbq('track', 'Lead')Form submission, sign-up
CompleteRegistrationfbq('track', 'CompleteRegistration')Account created
Searchfbq('track', 'Search')Site search performed
AddPaymentInfofbq('track', 'AddPaymentInfo')Payment details entered
Subscribefbq('track', 'Subscribe')Subscription started

Custom Events

For actions not covered by standard events:

fbq('trackCustom', 'PricingPageView');
fbq('trackCustom', 'VideoWatched', {video_name: 'demo'});
Quick Knowledge Check
Test your understanding

An online store wants to track how much revenue each Facebook ad generates. Which standard event (with which parameters) do they need?

💡
Hint: Think about what data Facebook needs to calculate return on ad spend.

How to Verify Your Pixel Is Working

Facebook Pixel Helper (Chrome Extension)

  1. Install the Meta Pixel Helper Chrome extension
  2. Visit your website
  3. The extension icon shows a number for each Pixel event detected
  4. Click it to see which events fired and any errors

Events Manager Test Events

  1. Go to Events Manager → your Pixel
  2. Click "Test Events"
  3. Enter your website URL
  4. Browse your site in a new tab
  5. Events appear in real-time in the Test Events panel

What to Check

  • PageView fires on every page
  • Your Pixel ID matches
  • No duplicate Pixels on the same page
  • Standard events fire on the correct pages
  • Purchase events include value and currency

Facebook Pixel Use Cases

1. Retargeting Audiences

Create audiences based on website behavior:

  • All website visitors (last 30/60/90/180 days)
  • Product page viewers who didn't purchase
  • Cart abandoners who didn't complete checkout
  • Past purchasers for upsell campaigns
  • Blog readers for awareness campaigns

2. Conversion Optimization

Tell Facebook what you want (for a full breakdown, read our Facebook funnel strategy guide):

  • Optimize for purchases, Facebook shows ads to users most likely to buy
  • Optimize for leads, targets users likely to fill out forms
  • Optimize for landing page views, targets users who will actually load the page

3. Lookalike Audiences

Build audiences of new people who resemble your best customers:

  1. Create a Custom Audience of purchasers (use your Facebook target audience guide to define segments)
  2. Build a Lookalike from that audience
  3. Facebook finds users with similar behavior patterns
  4. Target the Lookalike with prospecting ads

4. ROAS Tracking

With the Purchase event and value parameter, you can:

  • See exact revenue generated by each ad
  • Calculate return on ad spend (ROAS)
  • Compare performance across campaigns (check our Facebook CPM benchmarks to see how you stack up)
  • Make data-driven budget decisions

iOS 14+ and Privacy Changes

Since iOS 14.5, Apple requires apps to ask permission before tracking. This affects the Facebook Pixel.

What changed:

  • Many iPhone users opt out of tracking
  • Pixel data is less complete (significant data loss on iOS devices that opt out)
  • Attribution window shortened to 7-day click

How to adapt:

  • Use Conversions API alongside the browser Pixel (captures more data)
  • Verify your domain in Business Manager
  • Configure 8 priority events per domain (Aggregated Event Measurement)
  • Use UTM parameters as a backup tracking method
  • Trust Facebook's modeling, it estimates conversions even without full data
Quick Knowledge Check
Test your understanding

Why does Facebook recommend using the Conversions API alongside the browser Pixel after iOS 14.5?

💡
Hint: Think about the difference between browser-side and server-side tracking.

Common Facebook Pixel Mistakes

MistakeFix
Multiple Pixels on one pageRemove duplicates; use one Pixel per ad account
Pixel not in <head>Move it above </head> so it loads first
No Purchase valueAlways include {value: X, currency: 'USD'}
Not testing after installUse Pixel Helper and Test Events immediately (avoid common Facebook ads split testing errors too)
Ignoring Conversions APISet it up to capture events that browser ad blockers miss
Wrong event on wrong pageViewContent on product pages, Purchase on thank-you page

Frequently Asked Questions

Is the Facebook Pixel free?
Yes. Creating and installing the Pixel costs nothing. You only pay when you run Facebook Ads.
Facebook Pixel vs Meta Pixel, what's the difference?
They're the same thing. Facebook rebranded to Meta, so "Facebook Pixel" is now officially "Meta Pixel." The functionality is identical.
Does the Facebook Pixel slow down my website?
The impact is minimal, typically 50-100ms on initial page load. It loads asynchronously, so it doesn't block your page content from rendering.
Do I need a Facebook Pixel if I'm not running ads?
It's still worth installing. The Pixel collects audience data from day one. When you eventually run ads, you'll have a rich audience to retarget instead of starting from zero.
How many Facebook Pixels can I have?
One per Facebook ad account (up to 100 per Business Manager). Most businesses only need one Pixel across their entire website.
Is the Facebook Pixel affected by ad blockers?
Yes, some ad blockers prevent the Pixel from firing. This is why Facebook recommends also setting up the Conversions API for server-side tracking that isn't affected by browser ad blockers.
Can I use the Facebook Pixel on Shopify?
Yes. Go to your Shopify admin, then Settings, then Online Store, then Preferences, and paste your Pixel ID in the Facebook Pixel field. Shopify handles the code installation automatically.
Does the Facebook Pixel work with Google Tag Manager?
Yes. Create a new Custom HTML tag in Google Tag Manager, paste the Pixel base code, and set the trigger to All Pages. This is one of the most common installation methods.
How do I know if my Facebook Pixel is working?
Install the Meta Pixel Helper Chrome extension and visit your website. The extension icon will show how many Pixel events fired on the page. You can also use the Test Events tool in Facebook Events Manager.

Was this article helpful?

Let us know what you think!

#SocialMedia#ContentStrategy#DigitalMarketing

📚 Continue Learning

More articles to boost your social media expertise