How to Add a Facebook Pixel to Your WordPress Website

Date
Oct 20, 2021
Aug 25, 2020
Time
14 mins
On this page
How to add a Facebook Pixel to WordPress

How do you manage competition with your WordPress website now that WordPress has the largest share of websites running on content management systems (CMS)?

You can still stand out and achieve your business goals if you add the Facebook pixel to your WordPress website to obtain visitor activity data and use it to improve your ad targeting. The Facebook pixel collects information about the actions performed by your WordPress website visitors from the moment they enter your site to the moment they exit it.

In this article, you will learn what the Facebook Pixel is and why you should install it on your WordPress website. You will also find out how to install it on your website manually and with some of the best Facebook pixel WordPress plugins to collect accurate data.

What is Facebook Pixel?

The Facebook Pixel is a tracking code generated from your Facebook ad account and implemented on the header section of your website.

It captures specific actions visitors perform on your site and provides you with data to help you refine your Facebook and Instagram advertising campaigns to maximize performance.

You can use the data your Facebook Pixel records to show your ads to different audience segments based on their actions on your site. After creating custom audiences based on your Pixel data, you can also use them to create lookalike audiences to acquire new customers.

The Facebook Pixel is created and managed using the Facebook Business Manager.

I don't want to go too deep into technicalities, but if you're interested, we have an excellent article explaining in further detail how does Facebook Pixel work.

Why should I add a Facebook Pixel to my WordPress website?

The Facebook Pixel has great importance in three areas: Audience creation, measurement, and optimization.

the Facebook Pixel's importance in 3 areas: audience creation, measurement, and optimization

Let's break it down into the 7 main benefits of adding the Pixel to your WordPress website.

1. Gather audience insights

You can still set up and benefit from a Facebook Pixel even if you are not ready to run Facebook ads yet.

Even if you don’t know yet which events you should track, the Pixel automatically tracks Page Views, and you can also turn on Automatic Events to let it automatically track essential website actions.

If you start collecting data on your website visitors now, it’ll be much easier for you to optimize your ads in the future.

This way, you won’t need to start from scratch when you decide to run ads - you’ll already have data to work with.

2. Create custom audiences

The key insights you get from visitor activities on your website can help you create custom Facebook audiences for retargeting.

Using your Facebook Pixel data you can create various audiences based on their actions on your website.

Some examples of powerful audiences you can create are people that visited certain product pages, added to cart, or completed sign-up on your website. You can use this information to tailor ads to audience segments.

3. Create lookalike audiences

The data used to create custom audiences also allows you to build lookalike audiences based on them. These are users who share similar characteristics with your source audience.

Facebook uses artificial intelligence to identify these people among its users and allows you to create a large audience with traits similar to people who showed interest in your product or service.

You can then target these people and increase your chance to drive conversions and expand your customer base. Lookalike audiences are one of the most powerful tools for acquisition prospecting campaigns.

4. Track conversions

As you run Facebook ads, you aim to maximize your return on ad spend (ROAS). In order to measure that, you need to use a Facebook Pixel to track your website conversions.

The Pixel will provide you with key information about all the different actions people take on your website and will help you assess how much revenue your ads are making for you.

This information will be available for you in the Facebook Ads Manager, where you can implement your insights to optimize your ads.

5. Optimize for conversions

The Facebook Pixel grants you the ability to launch ad campaigns targeting the audience with the highest probability to convert.

If you are trying to target an audience that will drive you the most sales, Facebook will display your ads to people who are more likely to take a Purchase action.

This can be achieved by defining the suitable campaign objective, but conversion optimization is only possible if you have the Facebook Pixel installed on your website.

6. Facebook ads optimization for maximum value

The data you obtain from your Facebook Pixel provides information about customers who purchase on your website and about the amount they spent.

You can use this Pixel information to show your ads to the “big spenders” - your most profitable customers. You can also use this audience as a basis for a lookalike audience that is prone to drive conversions.

7. Dynamic product ads

Facebook Dynamic Product Ads

Sometimes people may visit your website and click on products but not complete the purchase. They may even add the product to their wishlist or cart and abandon it there.

The Facebook Pixel will work out the magic for you to reach out to such people as they could still be potential buyers. The Pixel data allows you to retarget these visitors with ads showing the same product they were interested in. These ads are called dynamic product ads.

This was a brief summary of the great advantages of the Facebook Pixel. You can, of course, read another article in order to learn how to use Facebook Pixel in ads.

If you're planning a Black Friday/Cyber Monday campaign (or any other big sale), you should check out our 10 Black Friday/Cyber Monday tips for Facebook advertisers.

How to add a Facebook Pixel to a WordPress website

If you didn’t create a Facebook Pixel yet, you should read our article about creating a Facebook Pixel.Do you have a Facebook Pixel already? Great!Let’s install it on your WordPress website then.

How to add a Facebook Pixel to a WordPress website

Note that in order to install it on your website, you need Admin-level access to your WordPress dashboard.

Go to the Events Manager, select your Pixel, and click “Continue Pixel Setup”.

There are different methods to install it on your website - manually or using a plugin.

Using a manual code

  1. Select “Install Code Manually”.
  2. The pop-up window will show you how to locate the header section of your WordPress website, which is where you should insert the Facebook Pixel base code.
  3. Copy the Pixel base code.
  4. In your WordPress dashboard, select “Appearance” on the left-side menu, and click “Theme Editor”.
WordPress dashboard
  1. Locate the Theme Header (header.php).
Locate the Theme Header - WordPress
  1. Paste the base code at the bottom of the header section, just above the closing head tag.
  2. Click “Continue”.
  3. At this stage, you can turn on “Automatic Advanced Matching” and verify the customer information you want to send. This is only optional and I’ll explain more about it later on.
  4. Click “Continue”.
  5. Add Events using the Events Setup Tool or by manually adding the relevant code to your website. More about Facebook Pixel Events later.
  6. Click “Done”.

Using a plugin

If you are looking for the easiest way to install a Facebook pixel on your website, there are plugins that can help you do the job.

Here are some of the best Facebook Pixel WordPress plugins that are currently available:

Insert Headers and Footers

add Facebook Pixel to WordPress with Insert Headers and Footers plugin

This plugin lets you insert code scripts into your WordPress website to connect Google Analytics, Facebook Pixel, custom CSS, and more.In order to install it, follow these steps:

  1. Go to the WordPress plugin directory and search for the “Insert Headers and Footers” plugin.
  2. Click “Install”.
  3. Click again to activate the plugin or activate it later via the “Plugins” menu on your WordPress dashboard.
  4. After your plugin is activated, copy your Pixel code from the Facebook Ads Manager.
  5. Select “Settings” in your WordPress dashboard and click on “Insert Headers and Footers”.
  6. Insert the Pixel code in the “Scripts in Header” and click “Save”.

PixelYourSite – Your smart PIXEL (TAG) Manager

add Facebook Pixel to WordPress with PixelYourSite plugin

This plugin can be used to manage your Facebook Pixel or google analytics code and add any other script to your website’s header or footer.

It also has an add-on for implementing the Pinterest Tag on your website.

This plugin automatically tracks important actions your website visitors take, such as searches, form submissions, comments, and downloads. Then, it sends them to all of your Pixels.

It also supports WooCommerce and Easy Digital Downloads.

In order to install it, follow these steps:

  1. Search for the “PixelYourSite” plugin in the WordPress plugin directory.
  2. Click to install and click again to activate.
  3. Log on to your Facebook Ads Manager and copy your Facebook Pixel ID.
  4. Click on PixelYourSite on your WordPress dashboard to open the plugin dashboard.
  5. Paste your Facebook Pixel ID in the grayed-out “Facebook Pixel ID” field.
  6. Click on “Save Settings”.

Pixel Cat – Conversion Pixel Manager

Pixel Cat plugin

Formerly known as “Facebook Conversion Pixel”, this plugin lets you add the Facebook Pixel to your website in a matter of minutes.The Pixel Cat plugin lets you set up Facebook Pixel standard events easily and even add parameters to create custom conversions.In order to install it, follow these steps:

  1. Search for the “Pixel Cat” plugin in the WordPress plugin directory.
  2. Click to install and click again to activate.
  3. Copy your Pixel code from the Facebook Ads Manager.
  4. Enter the Pixel Cat plugin on your WordPress dashboard.
  5. Insert the Pixel code in the right place.

Remarketable

Remarketable plugin

This plugin lets you add a meta box to each of your posts and pages allowing you to add events to each page separately.The Remarketable plugin helps you install standard and even custom events and supports WooCommerce.In order to install it, follow these steps:

  1. Install the “Remarketable” plugin from the WordPress plugin directory.
  2. Click again to activate.
  3. Copy your Pixel ID from the Facebook Ads Manager.
  4. Paste your Facebook Pixel ID into the plugin settings.

Facebook Pixel standard events

Christmas at the office

The next step, after adding the Facebook Pixel to your WordPress website, is setting up your desired events.

You can either do it manually using the relevant event codes or via Facebook’s Event Setup Tool. Read another one of our articles to learn how to set up standard events.

Facebook Pixel standard events are a means by which Facebook’s intelligent machine learning models decipher and relay audience insights, measurements, and ad targeting performance metrics.

These are Facebook’s standard Pixel events that you can add to your WordPress site:

  • Add Payment Info: The addition of billing information, such as a credit card, during the checkout process.
  • View Content: A visit to a web page that is important to you, such as a product or a landing page. This event only tells you that someone visited a specific URL, but not what they did or see on the page.
  • Add to Cart: The addition of an item to a shopping cart or basket.
  • Add to Wishlist: The addition of an item to a wishlist.
  • Complete Registration: A submission of information by a customer in exchange for a service provided by your business, such as signing up for your email list.
  • Contact: A phone call, SMS message, email, chat conversation, or any kind of contact between a customer and your business.
  • Customize Product: The customization of a product via any kind of configuration tool or app your business has.
  • Donate: A donation made to your organization or cause.
  • Find Location: When a person finds one of your locations with an intention to visit. For example, searching for a product on your website and finding it in one of your stores.
  • Initiate Checkout: The start of a checkout process.
  • Lead: A submission of information by a customer with the understanding that they may be contacted by your business later on. For example, signing up for a trial.
  • Purchase: The completion of a purchase, usually signified by receiving purchase or order confirmation, or a transaction receipt.
  • Schedule: The booking of an appointment to visit one of your locations.
  • Search: A search performed on your website, app, or other property.
  • Start Trial: the start of a free trial of a product or service you offer.
  • Submit Application: The submission of an application for a product, a service, or a program you offer, such as a credit card, an educational program, or a job.
  • Subscribe: The start of a paid subscription for a product or service you offer.

Custom conversions

When should you create additional custom Facebook Pixel conversions beyond the standard events you installed on your WordPress site?

Do it when you want to tell Facebook what’s the value of specific conversions for you.

You can also use customization to distinguish between people who viewed different pages on your website, such as different product pages. Later on, you’ll be able to show them exactly the ads they're interested in.

Custom conversions use URL rules based on specific URL or URL keywords, domains, or additional parameters.

Read another one of our articles if you wish to learn how to set up custom conversions on your WordPress site.

For better clarity, let us now understand custom conversions with a couple of hypothetical situations.

Custom conversion example #1

Let us assume that you have an eCommerce business that sells products for different pets, such as dogs, cats, fish, and birds.

When creating future campaigns, you’d like to retarget people with ads offering the products that are most relevant for them. Therefore, you’d like to distinguish between people who have fish at home and bird owners, for example.

That is very easy to do with custom conversions: Just create URL-based rules for the View Content conversions for each of the relevant pages on your website.

Another way to do it is by using event parameters, such as content_category, content_ids, or content_type. In this case, you’ll need to set up a product catalog, but the advantage is that every product you add to a specific category will be automatically added and fire the relevant custom conversion.

After setting up these custom conversions, you can segment your website visitors and create custom audiences for retargeting. Afterward, you’ll be able to create lookalike audiences for acquisition based on these custom audiences.

This way you’ll be able to target fish lovers with ads that are relevant for them and bird fans with ads that will be especially attractive for them.

Custom conversion example #2

A very general example that can apply to many types of businesses is tracking “big spenders”.

Let’s say you have an online eCommerce store, and you set up a Purchase event. It may be that not every purchase on your store has the same value for your business. Some customers may buy more products or more expensive products than others.

This is why it’s essential to customize your Purchase events using the value parameter to identify people who made especially big purchases on your website.

custom pixel convesrions - big spenders

Custom events

The next level of customization is called “custom events”.

These events are needed when you have important steps of the funnel that are not included in the standard ones. Every step of your funnel should trigger a Pixel event.

For example, if you have a questionnaire, your Pixel should fire an event for each step of the form.

In order to create such Facebook Pixel events, you have to add the relevant Javascript code to the relevant page on your WordPress website.

Pro Tip: Don’t create custom events that are meant to replace standard Pixel events. If Facebook has already created a standard event, such as Purchase, for example, use it when the event is a purchase. Facebook knows best how to find people who are likely to purchase and will optimize your ads for this type of conversion if you set it up correctly. However, if you create a custom event that is meant to replace it, Facebook won’t be able to optimize for it properly, and you might miss out on potential customers.

Offline events

All of these Facebook Pixel events are great and very helpful when it comes to tracking actions people take on your WordPress website.

But what if, in addition to your eCommerce store, you also have a store “in the real world”?

How can you track the effect your online advertising has on sales in your “real-world” store?

Have no fear, Facebook offline events are here!

Tracking your offline conversions will allow you to get a full view of your ad performance and also let you create custom and lookalike audiences based on visitors to your “real-world” store.

Efficiently monitoring offline events is essential for implementing a successful omnichannel marketing strategy.

Read another one of our articles if you wish to learn how to set up offline events.

How to check if your Facebook Pixel is working?

How to check if your Facebook Pixel is working

The most simple way to check that your Facebook Pixel was successfully installed on your WordPress site is by utilizing Google Chrome’s Facebook Pixel Helper extension.

This extension is now also available for Microsoft Edge and not only for the Chrome browser.

The Pixel Helper will show you whether your Pixel is active and help you troubleshoot different issues.

Use this link to add the Facebook Pixel Helper Chrome extension to your browser and go to your website.

If your Pixel is working, the extension icon will turn blue, and it will show the number of active Pixels on the website. Check also that the Pixel installed on your website has the same ID as the one you see in the Events manager.

Clicking on the extension icon will open a pop-up window, that will tell you whether your Pixel is working properly. If not, an error notification will appear.

You can troubleshoot Pixel-related issues using Facebook’s Diagnostics and Test Events tools. Facebook’s Test Events tool will help you test that your Pixel registers events properly.

Key takeaways

Now you know why it’s so important to add a Facebook pixel to your WordPress website.

The Facebook Pixel can provide you with key data about your website visitors’ activity as they interact with your site.

You can then use that information to tailor better Facebook ads targeting different audience segments based on their activities on your website.

It will also help you monitor conversion rates and improve your ads’ performance to optimize your return on ad spend.

As you’ve seen, it’s easy to add the Facebook Pixel to your WordPress site. You can either do it manually or using a plugin.

The last stage is setting up the events you wish to track. Now it's time for you to get more information and tips regarding Facebook Pixel events.

*Contributed to the article: Caleb M.

Date
Oct 20, 2021
Aug 25, 2020
Yuval Yaary

Yuval is the head of Content Marketing at Madgicx. He is in charge of the Madgicx blog, the company's SEO strategy, and all its written marketing materials.

Start your 7-day free trial today

Get Started
Get Started
No credit card required
Free training + 24/7 support
No results? Get a free trial extension