Facebook Tips & Strategies

How to Add a Facebook Pixel to a Website

By Spencer Lanoue
November 11, 2025

Setting up the Meta Pixel is one of the most powerful moves you can make for your marketing, and it’s easier than it sounds. This game-changing bit of code unlocks the data you need to make your Facebook and Instagram ads dramatically more effective, helping you reach the right people at the right time. This guide will walk you through exactly how to create your Pixel, install it on your website using the three most common methods, and confirm everything is working correctly.

What is the Meta Pixel? (And Why You ABSOLUTELY Need One)

Before 2021, you knew it as the Facebook Pixel. Now it's the Meta Pixel, but the function is the same: it's a small piece of code you place on your website that acts as a bridge between your site and your Meta (Facebook and Instagram) ad campaigns. Think of it like a smart and helpful assistant in your online store. It observes which products visitors look at, what they add to their cart, and what they ultimately purchase. It then reports this activity back to you so you can understand your customers better.

This "assistant" is critical for three main reasons:

  • It Tracks Conversions. The Pixel accurately measures the actions people take on your website after seeing your ad. Whether they made a purchase, signed up for a newsletter, or downloaded a PDF, the Pixel connects that action directly back to the specific ad that drove it. This is how you calculate your return on ad spend (ROAS) and find out which campaigns are actually making you money. Without it, you’re just guessing.
  • It Optimizes Ad Delivery. Once the Pixel understands what a "conversion" looks like for your business (like a purchase), Meta's algorithm gets to work. It uses the data to find more people who are likely to take that same action. It automatically shows your ads to users who share similar characteristics with your past customers, making your ad budget go much further.
  • It Allows for Powerful Retargeting. Have you ever looked at a product online, only to see an ad for it in your Instagram feed an hour later? That’s the Pixel at work. It lets you create highly specific Custom Audiences based on user behavior. You can target people who visited a specific page, abandoned their shopping cart, or haven't visited your site in 60 days. This ability to re-engage warm leads is one of the single most effective tactics in digital marketing.

Before You Start: The Essentials

You only need a couple of things to get started. Don't worry, you probably already have both.

  • Admin access to your website. You need to be able to either add code to your site’s header or install a plugin/app. If you built the site yourself or manage it regularly, you're all set. If not, you may need the help of your web developer.
  • A Meta Business Account. To create and manage a Pixel, you need a Business Account (formerly Business Manager). This is the central hub for all your professional Meta marketing activities. If you don’t have one yet, you can create one for free at business.facebook.com.

Step-by-Step: How to Create Your Meta Pixel

First, you need to generate the Pixel itself within your Meta Business Account. This process creates a unique ID and the accompanying code for your business. It only takes a minute.

  1. Navigate to Events Manager. You can find this by logging into your Meta Business Suite, clicking the "All Tools" hamburger menu (☰), and selecting "Events Manager."
  2. Click the green plus icon (+) that says "Connect Data Sources" on the left-hand menu.
  3. A window will pop up asking what you want to connect. Select Web and click "Connect."
  4. Give your pixel a name. It’s best to name it something clear, like “[Your Business Name] Pixel.” This helps you stay organized if you manage multiple assets. Click "Create Pixel."
  5. Next, it will ask for your website URL. Enter your full URL (e.g., https://www.yourwebsite.com) and click "Check."
  6. Meta will ask you how you want to connect your website. Here is where you’ll choose your installation method, which we’ll cover in the next section.

That's it! Your pixel now exists and has its own unique ID. Now you just need to place it on your website.

How to Add the Meta Pixel to Your Website (3 Ways)

Getting the code from Events Manager onto your website is the most technical part of the process, but website platforms have made this much easier over the years. We’ll cover the three primary methods, from the most beginner-friendly to the most advanced.

Method 1: The Easiest Way - Using a Partner Integration

If your website is built on a popular platform like Shopify, WordPress, Squarespace, Wix, or BigCommerce, this is the method for you. Meta has direct integrations with these platforms that make installation a guided, no-code process. You don't have to touch a single line of code.

In the setup wizard from the previous step, choose "Use a partner integration." You’ll see a list of platform logos. Find yours and follow the on-screen instructions. The exact steps vary by platform, but here are two common examples:

For Shopify:

Shopify’s integration is incredibly straightforward. During setup, Meta will guide you to your Shopify admin. You’ll simply:

  1. Go to your Shopify store's "Apps and sales channels" section and install the "Facebook &, Instagram" sales channel.
  2. Follow the steps to connect your Meta Business Account.
  3. Select your ad account and the Pixel you just created from a dropdown menu.
  4. Shopify handles everything else. It will automatically add the Pixel to every page of your store and even set up standard e-commerce events like ViewContent, AddToCart, and Purchase for you.

For WordPress:

Installation is usually done with a plugin. The Meta Partner Integration will prompt you to download their official "Meta Pixel for WordPress" plugin. Once it's installed on your site, you just log in to your Facebook account through the plugin, and it syncs everything automatically.

Alternatively, many people prefer using a simple plugin like "Insert Headers and Footers." This plugin gives you a field where you can paste code snippets directly into your site’s header. If you choose this route, you would simply use Method #2 below to get your code and paste it into the plugin's "Header" box.

Method 2: The Manual Method (Copy &, Paste)

This method involves copying the base code for the Pixel and pasting it directly into your website's source code. It’s best for custom-built websites or for users who are comfortable editing code files.

In the setup wizard, choose "Install code manually." Meta will display a code block. Click the "Copy Code" button.

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

Here’s what to do with that code:

  1. Navigate to the code editor for your website. You’re looking for the main or global header file. This template is often named header.php, head.html, or something similar.
  2. Find the opening <,head>, tag and the closing <,/head>, tag.
  3. Paste the entire Meta Pixel code just before the closing <,/head>, tag. It’s important to place it in the header so it loads on every single page of your website.
  4. Save your changes and upload the file back to your server.

The biggest risk here is pasting it in the wrong place or accidentally deleting other important code. If you’re not 100% sure, the Partner Integration or Google Tag Manager methods are safer.

Method 3: The Flexible Method (Google Tag Manager)

If you're already using Google Tag Manager (GTM) to manage other third-party scripts (like Google Analytics), this is the cleanest and most scalable way to add your Pixel.

  1. From Meta Events Manager, copy your Pixel ID. It's just a string of numbers.
  2. Log in to your Google Tag Manager account and go to your workspace.
  3. Click "New Tag." Name it something like "Meta Pixel - Base Code."
  4. Click "Tag Configuration" and search the Community Template Gallery for the "Facebook Pixel" tag template by facebookarchive. Add it to your workspace.
  5. Paste your Pixel ID into the designated field in the tag configuration. Leave the default event ("PageView") as is.
  6. Next, click "Triggering." Choose the "All Pages" trigger, as you want the base pixel to fire on every page load.
  7. Save, then click "Submit" in the top right to publish your changes.

Did it Work? How to Verify Your Pixel Installation

Once you’ve installed the code, you must verify that it’s actually firing correctly. Thankfully, Meta provides a couple of great tools for this.

Using Meta's Test Events Tool

Back in Meta Events Manager, find the "Test Events" tab. Enter your website URL into the box and click "Open Website." As you click around your site, you should see activity appear in real-time back in the Test Events tab. If the "PageView" event shows up, your base installation was a success!

Using the Meta Pixel Helper Chrome Extension

This is an indispensable tool for anyone running Meta ads. It’s a free browser extension from Meta that diagnoses your pixel installation on any site you visit.

  1. Install the "Meta Pixel Helper" from the Chrome Web Store.
  2. Navigate to your website. Click the Pixel Helper icon in your browser's toolbar.
  3. A small dropdown will appear. If it finds one or more Pixels and a "PageView" event with a green checkmark, you're good to go. If it shows an error, it will provide suggestions for fixing it.

What's Next? Setting Up Conversion Events

Getting the base Pixel installed is just the first step. The real magic happens when you tell the Pixel which specific actions to track. These are known as "events." Standard events include things like:

  • AddToCart: Someone adds a product to a shopping cart.
  • Purchase: Someone completes a checkout.
  • Lead: Someone submits a form.
  • ViewContent: Someone views a key page, like a product page.

To set these up without coding, Meta provides the powerful Event Setup Tool. You can access this from Events Manager. It opens your website in an overlay and allows you to add events simply by clicking buttons on your website and assigning them to a standard event. For instance, you can click your "Add to Cart" button and tell Meta that this action corresponds to the AddToCart event. This allows you to track and optimize for the specific moments that define success for your business.

Final Thoughts

Installing the Meta Pixel opens up incredible advertising capabilities, allowing you to track visitor actions, optimize campaigns for valuable conversions, and retarget interested users. Whether you choose the path of a partner integration, a manual install, or a tag manager, getting your pixel online is the foundational step toward smarter, more effective advertising on Facebook and Instagram.

Once your ads are bringing new visitors to your website, keeping them engaged is the next piece of the puzzle. At Postbase, we help you master the organic social media strategy that complements your ad spend. By making it easy to plan your content in a visual calendar, schedule video-first posts across Instagram and TikTok, and manage all your conversations in one inbox, we empower you to build a thriving community. Great ads earn the first click, but great content earns the follow.

Spencer's spent a decade building products at companies like Buffer, UserTesting, and Bump Health. He's spent years in the weeds of social media management—scheduling posts, analyzing performance, coordinating teams. At Postbase, he's building tools to automate the busywork so you can focus on creating great content.

Other posts you might like

How to Add Social Media Icons to an Email Signature

Enhance your email signature by adding social media icons. Discover step-by-step instructions to turn every email into a powerful marketing tool.

Read more

How to Record Audio for Instagram Reels

Record clear audio for Instagram Reels with this guide. Learn actionable steps to create professional-sounding audio, using just your phone or upgraded gear.

Read more

How to Check Instagram Profile Interactions

Check your Instagram profile interactions to see what your audience loves. Discover where to find these insights and use them to make smarter content decisions.

Read more

How to Request a Username on Instagram

Requesting an Instagram username? Learn strategies from trademark claims to negotiation for securing your ideal handle. Get the steps to boost your brand today!

Read more

How to Attract a Target Audience on Instagram

Attract your ideal audience on Instagram with our guide. Discover steps to define, find, and engage followers who buy and believe in your brand.

Read more

How to Turn On Instagram Insights

Activate Instagram Insights to boost your content strategy. Learn how to turn it on, what to analyze, and use data to grow your account effectively.

Read more

Stop wrestling with outdated social media tools

Wrestling with social media? It doesn’t have to be this hard. Plan your content, schedule posts, respond to comments, and analyze performance — all in one simple, easy-to-use tool.

Schedule your first post
The simplest way to manage your social media
Rating