А Beginner’s Guide to Using Facebook Pixel for E-commerce

by Kristen Pinkman

Table of contents:
Back to the library


As an e-commerce store owner, you already know that Facebook is vital for your business. Thanks to its massive user base and hungry audience, Facebook can drive traffic and sales to e-commerce stores in any niche imaginable.

The Facebook pixel helps you run effective Facebook ads. It is critical for analyzing performance, better targeting and expanding your audience.

In this e-book, we will show you a step-by-step process of adding the Facebook pixel to your store. We will also show you how you can use this pixel to drive more conversions.

What is the 
Facebook pixel?

The Facebook pixel is essentially a piece of Javascript code that tracks user behavior on any page.

You can think of the Facebook pixel as a “black box” that captures lots of data from a user’s browser. You can later extract this data and analyze it to understand your users.

The pixel gives you a lot of data:

  • It measures conversions so that you know exactly how your ads are performing.
  • It records visitors that left without making a purchase so you can follow up with ads later.
  • It can help you advertise to people similar to your existing customers.

You can integrate this pixel with a number of tools such as Unbounce to run more targeted campaigns. If you are using Ecwid to sell online, you can integrate the pixel with your store without touching any code.

While there is nothing stopping you from running a Facebook ad campaign without this pixel, you will get far better insight into your performance if you add it to your store or website.

Suppose you run a t-shirt store. You want to run a remarketing campaign where you target people who’ve visited your best selling t-shirt page, but haven’t purchased anything.

With the help of the Facebook pixel, you can create a Custom Audience of people who have visited this page.

You can then offer these customers a 20% off coupon through a targeted Facebook ad to spur conversions.

Understanding the Facebook Pixel Code

The Facebook pixel code can be difficult to understand at first, even if you’ve used tracking code from AdWords or Google Analytics in the past. The good news is that you don’t have to know the tech details if you use it with Ecwid. You won’t deal with any coding, so this section is entirely optional for Ecwid store owners.

If you want to start using the pixel right away, jump to the next section.

Back to the pixel code. First, it has two parts: the base pixel code and the event code.

1. Base Pixel code

This is the base code that you’ll need to add to your site’s
< head >...< /head > section. Without it, Facebook can’t track user action, optimize ads or create custom audiences.

Here’s what the code looks like:

The highlighted numerical part after “init” is your Facebook pixel ID. This is unique to each ad account. The rest of the code remains the same for every account.

2. Event code

While you can use the pixel code by itself, Facebook makes it much easier to track specific events (such as adding a product to cart) using event codes.

This is a small piece of code that accompanies the pixel code. It looks something like this:

The event code tracks user actions (or “events”) on a page either as a result of Facebook ads or organic traffic.

You can add different event codes to different pages depending on what you want to track.

Facebook offers tracking capabilities for several “Standard Events” by default. You can see a full list on the next page.

This should cover the entire scope of operations for most e-commerce store owners. If you need to track events beyond this, you can create custom events.

For example, if you want to track the number of people who’ve viewed a certain page, you’d add this code to the page:

The part highlighted in blue is optional; it only serves to define what a page view is worth to you (for conversion tracking).

If you’re tracking an action that takes place immediately on page load (such as viewing a product page or reaching an order-confirmation page), you’ll want to add the event code to immediately after the < /head > tag.

On the other hand, if you’re tracking on-page actions, such as clicking a button, you’ll want to add the code inline, like this:

You don’t always need to use the event code, but it makes conversion tracking and creating custom audiences much easier.

How to Add Facebook Pixel to Your Ecwid Store

The Facebook pixel integration is available on Ecwid paid plans. The installation is easy for everyone regardless of technical skills. You just need to generate your Pixel ID and add it to your Control Panel.

Step #1: In your Facebook profile, click the drop-down menu on the right. Choose “Create Ads” (if you’ve never logged into Facebook Ads before) or “Manage Ads” (if you’ve used Facebook Ads before).

Step #2: You’ll then find yourself in the Ad Manager. Click the drop-down menu and select “Pixels”.

Step #3: On the next screen, click the green button “Create a Pixеl”.

Step #4: Name your Pixel and click “Next”.

Step #5: On the next screen, click “Copy and Paste the Code”.

Step #6:Copy the Pixel code, paste it into a .doc or .txt file, select your Pixel ID, and copy it.

Step #7: Go to your Сontrol Panel → Settings → General → Tracking and Analytics and paste your Facebook Pixel ID there. Save the changes.

Step #8: Then check if your pixel is working. Navigate to your store to get the pixel triggered. Then go back to your Ad Manager → Pixels and check your pixel’s status. The green light means it’s active. It might take up to twenty minutes to activate your pixel.

All your pixel activity will be displayed in your Ad Manager. There you’ll see the graph showing how many times the pixel was triggered. Below you’ll see the tabs with the stats for the pixelevents.

As soon as your pixel has gathered some data, you’ll be able to use it in all gears. Here is a step-by-step guide on creating your Facebook Ad campaign.

What are the Uses
of the Facebook pixel?

The Facebook pixel is a powerful tool for tracking your users and creating hyper-targeted experiences.

As an e-commerce store owner, you’ll mostly use it for the following:

1. Retargeting

Retargeting is a cookie-based technology that uses simple a Javascript code to anonymously “follow” your audience all over the Web, so you can advertise to them later.

Ever looked up for a product on Amazon and then saw it on Facebook later? That’s retargeting. Facebook knew you visited Amazon because Amazon placed bits of Facebook code (cookies) on its site.

Retargeting is one of the most effective display advertising tactics around.

According to a study by ComScore, retargeted ads lead to a 1046% increase branded search and a 726% lift in site visitation after four weeks of retargeted ad exposure.

As WebsiteSetup shows, adding cross-device retargeting significantly increases reach and CTR globally, while reducing CPC by as much as 35%.

As a recent MarketingLand article explained:

“It’s not uncommon to see amazing CTRs with retargeting, anywhere from 0.30-0.95% — which is 3-10x higher than the industry average.”

The Facebook pixel can be used to build audiences of people who have visited specific pages on your site.

Retargeting audiences on Facebook are created under the “Audiences” tab in Ads Manager.

To create an audience of people who have interacted with your Facebook pixel, click “Create Audience” → “Custom Audience”.

You’ll find plenty of ways to create your custom audience.

You can:

  • Import data from a CSV or text file (such as phone numbers, names, emails, etc.).
  • Import data from your MailChimp account.
  • Target people who have visited a specific page on your site.
  • Target people who have performed specific actions in your app.
  • Target people who have engaged with any content on your page.

For instance, if you want to target people who have viewed a product, you can select the “Website Traffic” option.

On the next screen, choose “People who visit specific pages”. Then select “URL Equals” and enter your exact url (such as “yoursite.com/your-product-page.html”).

You can change the tracking duration as well.

This will create a custom audience of anyone who has visited your product page in the last 7 days.

What if you want to exclude people who have bought from your store?

In this case, you can select “People visiting specific web pages but not others”, then include your “Thank you” order confirmation page URL, like this:

This will create a custom audience of anyone who has visited your t-shirt page but left without buying.

You can easily see the power of such hyper targeting.

2. Optimization

Before you set up any advertising campaign, Facebook asks you the objective of the campaign:

You can tell Facebook exactly what you want your campaign to do.

If you’re running something simple like a Lead Magnet opt-in or a sale, always use “Conversions” option as your objection.

Tell Facebook what to optimize for by using custom conversions on the page where visitors land directly after they perform your target action (such as buying a product).

This way you collect data and tell Facebook exactly what you want from the campaign. Facebook will then use its own internal optimization capabilities to fine tune your ads for your desired action.

3. Tracking

By using the Facebook pixel you can track how many times a particular action occurs. For instance, you can track how many products were sold from a specific ad.

This is achieved through the use of custom conversions as we saw earlier.

A Custom Conversion is created by selecting a completion page and naming the conversion. Usually the completion page is kind of a thank you page.

Custom Conversions can be created separately from your ads and use them later in the future. They can be found in the ad manager menu:

The Facebook pixel can easily track the completion page because it already fires on all your website pages.

You can choose the type of conversion, such as “Add to cart”, “Purchase” etc. It also lets you add a monetary value.

For example, if you create a Custom Conversion that tracks visitors to an ebook download page, you can include the cost of the ebook.

This feature helps you to figure out how profitable your ad campaigns are and if the pricing of your products is right.

Once you create a Custom Conversion, it will be tracked for all your ads, whether you choose to optimize for it or not.

You can see the number of particular conversions/events in Ad Manager Pixels:

When creating your campaigns, be sure to check the “track all conversion from my Facebook pixel” option at the ad level.


The Facebook pixel can take a while to understand, especially after Facebook merged all tracking Pixels into one. But once you start using it, you’ll realize its effectiveness, especially if you use retargeting.

Adding the Facebook pixel to your Ecwid store is dead easy, and once you’ve set it up, you can run all sorts of interesting promos to your best customers.

Go ahead and give the pixel a try.

Stay up to date!

Get free ecommerce tips, news and inspiring ideas right to your inbox