Warning: Declaration of ET_Theme_Builder_Woocommerce_Product_Variable_Placeholder::get_available_variations() should be compatible with WC_Product_Variable::get_available_variations($return = 'array') in /home/customer/www/bonus4you.net/public_html/wp-content/themes/Extra/includes/builder/frontend-builder/theme-builder/WoocommerceProductVariablePlaceholder.php on line 8
Supercharge Your Facebook Ads: How to Add Facebook Pixel to WordPress - Bonus4you.net

Select Page

Supercharge Your Facebook Ads: How to Add Facebook Pixel to WordPress

Supercharge Your Facebook Ads: How to Add Facebook Pixel to WordPress

Have you heard of Facebook Pixel, but are unsure what it is or whether you need to add it to your website?

In this article, we’ll be exploring exactly what Facebook Pixel has to offer you.

You can measure, track and optimize your Facebook advertising campaigns with the free Pixel analytics tool. I’ll show you how to add the Facebook Pixel tracking code to WordPress, and how to set up event tracking, so you can see exactly what people are doing on your website.

What Is Facebook Pixel?

Facebook Pixel is an analytics tool that’s designed to help you analyze and optimize your Facebook advertising campaigns. 

Since it’s Facebook-specific, you don’t need to add Facebook Pixel to your WordPress website unless you’re currently running or plan to run adverts on the Facebook platform. If you have no plans to advertise on Facebook, then you should opt for a more generalized analysis tool, such as Google Analytics.

If you do promote your WordPress website on Facebook, then you can use Pixel to: 

  • Measure the conversion rates from your Facebook advertising campaigns. For example, you can track how many people complete a purchase after clicking your Facebook ad. 
  • Target people based on their previous behavior. Pixel will record every visitor who takes action after viewing one of your Facebook ads. For example, Pixel can track the pages they visit and the products they add to their shopping baskets. You can then use this information to target visitors with personalized, dynamic adverts that are designed to encourage them to perform subsequent actions. 
  • Get the most out of your advertising budget. Set up automatic bidding to target the people who are most likely to act after viewing your ads. 

How Do I Add Facebook Pixel to My WordPress Website?

n this section, I’ll show you how to install Pixel to your WordPress website, by generating a Facebook Pixel tracking code and then pasting this code into your website’s header. 

Creating Your Pixel

You can only create one Pixel per Facebook Ads account, but if you have multiple websites then you can simply reuse the same Pixel. 

To create your Pixel:

  • Head over to the Facebook Events Manager and log in using your Facebook username and password.  
  • Find the Facebook Pixel card, and click its accompanying Get Started button.
  • In the subsequent popup, give your Pixel a name.
  • Review the Facebook Business Tools Terms, and if you’re happy to proceed then click Continue.
  • There are several ways that you can add a Pixel to your website, but we’ll be doing it manually, so click Manually add code to website.

Add the Facebook Pixel Code to Your Website

At this point, you’ll be presented with some JavaScript code that you need to add to your website’s header.

There are two ways that you can add this code to your site: either paste it into your header.php file or use a plugin. I’ll be adding the code to my website’s header.php file:

  • Log in to your WordPress account.
  • In the left-hand menu, select Appearance > Theme Editor.
  • Open the Select theme to edit dropdown and choose the theme you’re currently using. Click Select.
  • Scroll down the Theme Files menu until you find a header.php file—click it.

You should now be viewing the header.php code. Scroll until you find the last </header> tag, also known as the closing tag. Copy/paste your Pixel code directly above the closing </header> tag.

Save your changes by clicking Update File, and switch back to the Facebook Events Manager and scroll to Turn on automatic advanced matching. This feature is disabled by default, but if you enable it then Pixel will try to match your website’s visitors to their Facebook profiles, using information they’ve already provided to your website such as their name, email address, and phone number. 

Advanced matching can be useful for creating targeted ad campaigns, but sharing visitor information with a third party can be a sensitive subject, so I’d recommend clicking the Learn more link and reviewing Facebook’s information about advanced matching, before you commit to sharing your data.

You now need to check that Pixel is set up correctly. 

  • Scroll to the Test base code section and paste your website’s URL into the accompanying text field. 
  • Click Send traffic, and Facebook Events Manager will launch your website in a new tab.
  • In the new tab, spend some time triggering various events on your website, such as clicking buttons, adding items to your shopping cart, or navigating to different web pages.
  • Switch back to Facebook Events Manager, and it should update to display an Active message. Click Continue.

Congratulations—you’ve just added Facebook Pixel to your website! 

Event Tracking: See Exactly What Your Audience Are Doing

Next, we need to let Pixel know which events it should track. For example, you may want to record whenever a visitor access a specific webpage, selects a particular item in your menu, or adds an item to their shopping cart. 

Event tracking is a huge part of Facebook Pixel and powers many of its core features, but the process of implementing event tracking will vary, depending on the kind of activity you want to track and how your website is set up. 

To get started, it may make sense to set up some basic event tracking, analyze the generated data, and then use it to refine your tracking over time. 

In this step, we’ll be creating some basic events using Facebook’s Event Setup Tool. 

Currently, the Facebook Events Manager should be prompting you to Use Facebook Event’s Setup Tool. However, it can take the Event Setup Tool up to 20 minutes to register that Pixel is set up on your website. If you encounter a no events have been registered error message when you try to launch the Event Setup tool, then you’ll need to try again later.

  • In the Facebook Events Manager, select Use Facebook’s Event Setup Tool.
  • Assuming that the Events Manager has recognized that Pixel is set up correctly, enter your website’s URL and click Open website.
  • Your website will now launch in a new tab; click Next to move through the introductory dialogue. 

You’ll now be guided through the process of registering which events you want to track. This process will vary between websites—for example, if you wanted to record every time someone clicks the Add to Cart button, then you’d start by selecting Track new button.

The Events Setup wizard will then highlight every button on the current webpage, and you can select the button that you want to track. After making your selection, you can assign an event to this button, for example Purchase or Initiate Checkout.

Then, rinse and repeat for every event that you want to track. When you’re happy with your initial event tracking, click Finish Setup.

To put your tracking to the test, spend some time deliberately triggering the various events on your website, and then switch back to the Facebook Events Manager and select Test Events. The Events Manager should now contain a complete record of your recent activity. 

Based on the information that’s appearing in the Facebook Events Manager, you may want to make some tweaks to your event tracking, such as editing existing events or creating new ones. 

To refine your event tracking:

  • Open the Facebook Events Manager, if it isn’t already open.
  • Select the Set Up button towards the upper-right corner.
  • Click Set Up New Events.

Facebook will now launch the Events Setup Wizard, ready for you to refine your website’s event tracking. 


In this tutorial, I showed you how to get more out of your Facebook Advertising campaigns by adding Facebook Pixel to your website. I also outlined how you can start recording visitor activity, by setting up basic event tracking.

We’ve just scratched the surface of everything Facebook Pixel has to offer! If you’d like to learn more about this powerful analytics tool, then check out the Facebook Pixel documentation for more information. 


Video of the Month

must have

UNLIMITED DOWNLOADS: 1,500,000+ Logos & Design Assets

All the Logos you need and many other design elements, are available for a monthly subscription by subscribing to Envato Elements. The subscription costs $16.50 per month and gives you unlimited access to a massive and growing library of 1,500,000+ items that can be downloaded as often as you need (stock photos too)!

Get unlimited downloads 2,300,000+ top quality assets

UNLIMITED DOWNLOADS: 1,500,000+ Icons & Design Assets

All the Icons you need and many other design elements, are available for a monthly subscription by subscribing to Envato Elements. The subscription costs $16.50 per month and gives you unlimited access to a massive and growing library of 1,500,000+ items that can be downloaded as often as you need (stock photos too)!