Facebook Pixel: What It Is & How to Set It Up (2026 Guide)
TL;DR - Quick Answer
15 min readComprehensive 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 trialWhat 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
- Open Facebook Business Manager (business.facebook.com)
- Click Events Manager in the left menu
- Click "Connect Data Sources"
- Select "Web"
- 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:
- Copy the base code from Events Manager
- Open your website's HTML
- Paste the code between
<head>and</head> - Save and publish
Method 2: Google Tag Manager
- Open Google Tag Manager
- Create a new Tag, select "Custom HTML"
- Paste the Facebook Pixel code
- Set the trigger to "All Pages"
- Save and publish
Method 3: Platform-Specific Installation
Method 4: Conversions API (Server-Side)
For more reliable tracking (not blocked by ad blockers):
- In Events Manager → Settings → "Conversions API"
- Set up server-side event tracking
- Works alongside the browser Pixel for redundancy
- 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.
You've installed the Facebook Pixel via Google Tag Manager. Which trigger should you use so the base PageView event fires everywhere?
Facebook Pixel Standard Events
Standard events are predefined actions Facebook recognizes:
Custom Events
For actions not covered by standard events:
fbq('trackCustom', 'PricingPageView');
fbq('trackCustom', 'VideoWatched', {video_name: 'demo'});An online store wants to track how much revenue each Facebook ad generates. Which standard event (with which parameters) do they need?
How to Verify Your Pixel Is Working
Facebook Pixel Helper (Chrome Extension)
- Install the Meta Pixel Helper Chrome extension
- Visit your website
- The extension icon shows a number for each Pixel event detected
- Click it to see which events fired and any errors
Events Manager Test Events
- Go to Events Manager → your Pixel
- Click "Test Events"
- Enter your website URL
- Browse your site in a new tab
- 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:
- Create a Custom Audience of purchasers (use your Facebook target audience guide to define segments)
- Build a Lookalike from that audience
- Facebook finds users with similar behavior patterns
- 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
Why does Facebook recommend using the Conversions API alongside the browser Pixel after iOS 14.5?
Common Facebook Pixel Mistakes
Frequently Asked Questions
Is the Facebook Pixel free?
Facebook Pixel vs Meta Pixel, what's the difference?
Does the Facebook Pixel slow down my website?
Do I need a Facebook Pixel if I'm not running ads?
How many Facebook Pixels can I have?
Is the Facebook Pixel affected by ad blockers?
Can I use the Facebook Pixel on Shopify?
Does the Facebook Pixel work with Google Tag Manager?
How do I know if my Facebook Pixel is working?
Was this article helpful?
Let us know what you think!