Skip to content

The Facebook Pixel, Explained

Article by David Vranicar

Tucked away inside websites across the internet, the Facebook Pixel calmly watches what we do online. Whether we’re reading up on politics or adding items to a shopping cart, it keeps tabs for future reference.

And by “future reference,” we mean “future advertising.”

This post will take a closer look at the Facebook Pixel. But seeing as the pixel itself is an invisible snippet of code, we’ll need a visual stand-in. So let’s look at this lady and her blonde clip-in hair extensions.

facebook pixel works in the background

If you go to Luxy Hair’s website and add these hair extensions to your cart, it looks like this:

how facebook pixel works

Nothing to see here, right? Well, not exactly. In fact, the Facebook Pixel is going bananas.

fb pixel chrome developer tools

Let’s fire up Chrome’s “Developer Tools” to see what’s happening behind the scenes. There’s a filter for “facebook,” so all of the code and URLs and cookies popping up on the right are linked to Facebook.

Of course, if the Facebook Pixel chills out on the websites we visit and triggers ads later on, it can do the same for your website. Even if you’re running a one product store where there’s not much to track or advertise, you can still take advantage of this tool.

This post will go over:

  • What, exactly, the Facebook Pixel is
  • What it’s used for
  • How it works
  • How you can use it to optimize your Facebook ads

Don’t wait for someone else to do it. Hire yourself and start calling the shots.

Get Started Free

What Is the Facebook Pixel?

The Facebook Pixel is code embedded into a website that links visitors’ onsite behavior to Facebook user profiles. This sync between a website visitor and their Facebook account enables the social media platform to retarget those individuals with relevant ads. Additionally, it can be used to track the actions individuals take when they return to the website.

In Facebook’s own words, this code “is an analytics tool that allows you to measure the effectiveness of your advertising by understanding the actions people take on your website.”

While the Facebook Pixel is indeed used to “understand the actions people take” on websites, this definition is perhaps a bit incomplete. Because it uses this data to assign people to different target groups that will be engaged with ads later on.

No matter where the Facebook Pixel ends and Facebook advertising takes over, you get the idea. The Facebook Pixel:

  • Lives inside of websites
  • Tracks people’s actions while they’re there
  • Gives advertisers the ability to target them on Facebook properties
  • And enables companies to track the effectiveness of their paid social media campaigns

How Does the Facebook Pixel Work?

We’re going to get technical for a minute here. It won’t be painful – there will be lots of pictures and not a lot of jargon. But if you want to skip ahead to How to Install Facebook Pixel or How Do You Target People With the Facebook Pixel, no hard feelings.

Still here? Great. Now, let’s do some shopping!

We’re going to visit two stores today. The first is Esprit. The other is Nike. There is nothing unusual about these stores; they are simply being used to represent ecommerce in general. To be sure, neither Esprit nor Nike are doing anything unusual or sinister with their tracking and advertising. They’re just clothing stores going about their business and using Facebook pixel tracking to reach frequent visitors.

Let’s find something on Esprit. Oh, yeah – this white and blue sweater is nice:

And here is all the Facebook-related code spinning in the background:

The Facebook Pixel will know when we add the sweater to our cart:

Of course, we’ll never squeeze into that slim-fit sweater if we don’t stay in shape. So let’s head over to Nike for some new running gear, including these running pants:

Like Esprit (and every other ecommerce store), Nike has plenty of Facebook code keeping track of our visit:

But that won’t stop us from adding the item to our cart:

And Now for the Pixel Tracking Magic

Let’s say that we leave these sites without buying anything. Abandoned carts are a nightmare for every ecommerce shop, even the big boys.

Look at what happens the next time we go to Facebook:

A moment later, just to make sure we remember:

Another moment, and things get a bit less subtle:

Nike’s has their own Facebook Pixel ID, and their own ads:

Indeed, both companies’ Facebook Pixels seem to be working just fine:

The Facebook Loop

It’s impossible for us to know the sort of targeting rules that Esprit and Nike created for shoppers like us. For example, would we have seen so many ads if we hadn’t added these items to our carts? And maybe geography plays a role, too: Would these ads have appeared with the same frequency if we shopped from, say, South Korea instead of Germany?

The parameters of these companies’ Facebook campaigns – the rules, the target groups, the bids, the time period, and so on – are entirely unknown.

Even so, you can see how the Facebook Pixel operates.

  • A shopper visits the store and looks at products – maybe even adding a couple to their cart
  • The Facebook Pixel is sitting in the background, quietly taking notes on everything that happens
  • It then syncs with the Facebook cookies residing in the visitor’s browser and flags the account as part of certain target groups
  • Thanks to this data, when the shopper hops back on Facebook or Instagram, those platforms know what they’ve been doing, and which ads they should see

How to Install Facebook Pixel

Facebook has made installing the Facebook pixel thoroughly simple. As Facebook explains it,

Set up the Facebook pixel by placing pixel code on the header of your website. When someone visits your website and takes an action (like completing a purchase), the Facebook pixel is triggered and reports this action.

Pretty straightforward, right?

And if you use Shopify, it’s even easier to implement the analytics tool. You go to your Facebook Business Manager, copy the Pixel ID – not the code, just the ID – and then drop it into your Shopify store preferences:

To ensure your tracking pixel is correctly installed, download the Facebook Pixel Helper extension in Chrome. Now visit your site and run the extension to see if the pixel is working. Facebook Pixel Helper also informs you about errors – enabling you to redo the installation steps to ensure that it’s working correctly.

facebook pixel helper

If the Pixel Helper displays no errors, you can start viewing real-time event and conversion data in your Facebook marketing campaigns. 

It makes sense that installing the Facebook Pixel is as straightforward as copying and pasting. After all, having the Pixel on your site incentivizes you to advertise with Facebook, as well as Facebook-owned Instagram. That makes Facebook happy.

Facebook is also happy for you to use the Pixel because – whether you advertise with them or not – you are helping Facebook build richer profiles of its users. Having its tracking pixel scattered all over the internet lets Facebook know what its users are doing outside of the platform.

Not that anybody would ever accuse Facebook of being sneaky with data, but it is quite the coincidence that I saw this adidas ad on Instagram the same day I was shopping at Nike.

facebook pixel retargeting ad

At any rate, incentives are aligned with when it comes to installing the code in your store: You get better advertising, Facebook gets better data.

How Do You Target People With the Facebook Pixel?

If we’re being technical about it, the code doesn’t actually do any targeting. Instead, it is the foundation for targeting.

It’s up to you to tell Facebook how to target.

Inside of your Facebook Business Manager, you can create “Custom Audiences” with rules ranging from basic to super complex. For example, let’s say you sell fashion accessories, including sunglasses. The Facebook Pixel will know all the Facebook users who browsed your sunglasses, and when they did it. So you could have a Custom Audience of people who visited “sunglasses” pages on your website in the last, say, 30 days.

facebook pixel people who visited specific web pages

You can also target Facebook ads to people who have already converted. For instance, maybe you want to treat buyers with a discount code for their next purchase. You could do that by setting a URL rule for a post-conversion page –  like, say, a Thank You page.

You could flip that around and create a group of people who have been to your store but didn’t get to the Thank You page.

One more: You can create Custom Audiences based on the amount of money people spent at your store. A “Big spenders” segment could contain people you want to target with your more expensive items. (And you’ll know who the big spenders are thanks to the pixel.)

facebook pixel custom audience

Facebook Pixel’s Additional Targeting Options

Lookalike Audiences

One of the great things about Facebook advertising is “Lookalike Audiences.” You can design Lookalike Audiences to reflect the characteristics of your best customers.

The code knows who did what on your website, and the Facebook platform can use that data to identify people who share similar traits as your visitors. So if your “Big spenders” segment is full of 25-35 year old females who live in urban areas, Facebook can create a Lookalike Audience of other 25-35 year old females who live in urban areas and who Facebook thinks might be interested in your products.

Standard and Custom Events

You can also use it to create what are called “custom events,” which are the more evolved relative of “standard events.” Standard events are actions that the Facebook Pixel tracks automatically, like “add to cart” and “purchase” (there are nine total). Custom events, on the other hand, are events that you design yourself, allowing you, in Facebook’s words, “to define more granular data around events.” This could be all sorts of different stuff – scroll depth, button clicks, and video tracking, to name just a few.

Custom Conversions

Another fascinating thing about Facebook Pixel is the ability to create Custom Conversions. This is built by choosing a completion page, such as a Thank You page, and giving a name to the conversion. For example, you can use something like “thank you for subscribing, here’s your 20% discount” as the conversion name. And because the tracking pixel is already running on your website, it can track when someone arrives on a completion page.

facebook pixel custom conversions

You can also select a conversion category and enter a monetary value for the custom conversion. For instance, if you create one that tracks people to a product page, you can include the cost of the product. This can help you determine whether you’re earning a profit from your campaigns or need to make some tweaks. If the product is priced at $50, but you’re spending $60 for every conversion that comes via Facebook ads, it’s probably time to re-evaluate your campaign setup.

If you want to optimize ad groups for Custom Conversion, select “Website Conversion” as your Facebook advertising objective, type in your site’s URL, and then choose the conversion you want to track and improve upon. The current maximum number of custom conversions an ad account can have is 100, but Facebook gives you the freedom to delete the ones you’re not using and develop new ones.

Creating Facebook segments and ads is a science all its own. So for now, let’s leave it there.

The takeaway is that whether you’re using out-of-the-box events or customize more advanced events, the Custom Audiences you create are underpinned by Facebook Pixel data. It can tell you who looked at the sunglasses. It also knows who did and didn’t get to your Thank You page, and how much they spent.

Facebook Pixel Is One of Many Advertising Tools

Facebook isn’t the only advertising tech floating around the code of sites like Nike and Esprit. And that’s why we see the same sort of ads popping up all over the place – not just at Facebook.

Here, for example, is what a visit to The New York Times looks like a day after shopping around on these two online stores:

How does The New York Times also know that we were at Esprit? Well, they don’t. But tools like Criteo, which specializes in retargeting, sure do. Criteo is one of the 30 or so advertising tools hooked up with Esprit’s website. Just as the Facebook Pixel helps Facebook fill its ad space with relevant ads, the Criteo’s of the world help The New York Times fill its ad space with relevant ads.

There are, however, a few things that make Facebook unique in this ecosystem. First off, Facebook is huge. It has two billion-plus daily active users, and at least some of them are going to be part of your target audience.

Second, Facebook’s ad platform isn’t perfect, but for scrappy ecommerce store owners, it’s pretty great. Designing ads is relatively simple, creating target groups is manageable, and of course the Facebook Pixel ID is a breeze to install.

So even if you have ambitious retargeting plans, the Facebook Pixel should be one of the first tools you use.

Technical Details

If you want to get a better idea of the mechanics behind all the advertising that ecommerce stores are using, you can use the Ghostery browser extension. Every time you visit a new website, Ghostery will give you a list of the advertising, analytics, and engagement tools living on the site.

facebook pixel tracking

You can peer further underneath the hood with Google Chrome’s “Developer Tools,” which is standard in the Chrome browser. That’s the tool we used earlier to look at all of the code firing during our shopping trips at Esprit and Nike.

Make no mistake: You can run retargeting campaigns without knowing about this stuff. No problem. Just a heads up that there are some tools available if you want to dig around.


With Facebook advertising, you have several opportunities to engage and convert visitors even after you’ve shown them a front-end offer. The kind of data presented by the Facebook Pixel helps you retarget your ads to potential customers in the future. The analytics tool provides excellent insights into your audience, delivers ads to audiences who’ve shown interest in your business, and enhances the overall efficiency of your ad campaigns. Seriously, do your business a favor and tap into that pixel goodness!

Want to Learn More?

Facebook can be huge for your store’s advertising and reach. Here are some more Facebook goodies.