If you’re wondering how to add Facebook pixel to WordPress, you’re in the right place. In this straightforward tutorial, we explain what a Facebook pixel is, why you’d want to use it on your WordPress site, and how to set it up.
What is the Facebook pixel and why use it? 🔸
Let me just read you a part of the official definition, since it’s actually quite good:
The Facebook pixel is a snippet of code that lets you track visitor activity on your website.
Now, what sort of activity can you track?
This is entirely up to you. You can track whatever activity is important to you. The most common usage is to track conversions or events that lead to sales or other visitor interactions.
What basically happens is that the Facebook pixel works quietly in the background of your site, tracks all those events and the user actions that trigger them. Then, when the event happens, an information gets sent back to Facebook. You can then use that information as input points or feedback for your ad campaigns. It gives you insights about how your visitors interact with your site. You can also save ads, this way streamlining your workflow and consistently producing winning creative assets that drive results.
In the end, what the Facebook pixel allows you to do is make a connection between your site and the ad campaigns that you have running on Facebook. This, for example, lets you target ads to only those visitors who have seen a particular page or product on your site.
These sort of things are great at recovering abandoned shopping carts or getting the person back to your site in any other circumstances.
💡 Just to emphasize this, you only need the Facebook pixel on your site if you’re going to be running any ad campaigns with the Facebook Ads platform. Scratch that, it’s not that you need the Facebook pixel then, you absolutely must get it for your site! It will give you a whole new level of tracking capabilities with your campaigns.
How to create your Facebook pixel
Before you can add the Facebook pixel to your site, you have to first create it within the business section of the Facebook interface.
Depending on whether you’ve set your Facebook ad presence through your personal account or a business account, you’re going to use either the normal version of Facebook’s Events Manager or the Events Manager in Facebook Business.
Facebook Business is a more advanced area of Facebook, mainly meant for people working with multiple pages, ad accounts, and even client campaigns.
How to create a Facebook pixel when advertising through a personal account
To start, go to the Events Manager.
Click on the + Connect Data Sources button and select Web.
Select Facebook Pixel and click on Connect.
Add a name for your pixel and enter the website URL.
You will receive your personal Facebook pixel code at this stage.
Copy this code somewhere safe for the time being. We’ll use this snippet in a moment to enable the pixel on your WordPress website.
How to create a Facebook pixel in Facebook Business
Go to the main Business Settings in Facebook Business.
From the left sidebar, go to Data Sources → Pixels. Click on the Add button that’s in the center.
Enter a name for your pixel and the address of your website. Click on Continue.
In the next step, select the option to Set up the Pixel Now.
Lastly, select the option to Manually add pixel code to website.
In the next panel, you will get your unique Facebook pixel code.
You’ll use that piece of code in the next step, which is when we’ll finally add Facebook pixel to WordPress:
How to add Facebook pixel to WordPress using the Blocksy theme 👍
📋 Note; if your site doesn’t use the Blocksy theme, first of all, it should! Seriously, check it out! In the meantime, we do show you the manual method of adding the Facebook pixel to your site later in this guide as well.
The great thing about using Blocksy as your theme is that it can handle many additional side-elements that go beyond your website’s appearance. One of those side-elements is letting you add Facebook pixel to WordPress easily.
Moreover, with Blocksy, you can choose whether you want the Facebook pixel added to the entire website or just select pages/posts within the site. This type of setup can be useful if you’re only running Facebook campaigns that relate back to parts of your site and you don’t want to have Facebook lurking in the dark on every single sub-page.
Here’s how to add Facebook pixel to WordPress with Blocksy:
Activate the Custom Code Snippets extension
With Blocksy enabled as your theme, go to your wp-admin, into Blocksy → Extensions → Pro Extensions. (A Blocksy Pro subscription is required.)
Activate the Custom Code Snippets extension:
At this stage, you can pick whether you want to add the Facebook pixel only to select pages or your entire website:
Option a): Add the Facebook pixel to the entire website
Fire up the WordPress Customizer and scroll down to the Custom Code Snippets section in the sidebar.
Grab your Facebook pixel code and paste it into the Header scripts box:
Click on the Publish button to save the changes.
From now on, the Facebook pixel is enabled on all pages and posts within your website!
Option b): Add the Facebook pixel to select pages/posts only
If you want only a few select pages to have some interaction established with your Facebook ad campaigns, then there’s no need to add the pixel to the entire site. Blocksy lets you add the pixel only to the exact pages where it is needed.
When editing any post or page, click on the Blocksy icon in the corner and then scroll down to the Custom Code Snippets section:
Grab your Facebook pixel code and paste it into the Header scripts box:
Click on the Update button to save the post.
At this stage, the Facebook pixel has been enabled on a single page/post only. To add the pixel to more posts or pages, edit them one by one and repeat the steps above.
How to add Facebook pixel to WordPress manually
If your blog runs on a different theme than Blocksy, you can still add the Facebook pixel pretty easily. Use a plugin called Insert Headers and Footers for that.
Once you have the plugin activated, go to Settings → Insert Headers and Footers and paste your Facebook pixel code into the Scripts in Header section, like so:
This will add the pixel to the entire site. As far as adding the pixel to individual posts, this is not a feature that the plugin offers.
Alternatively, for an ultra-manual setup, you can also add the Facebook pixel snippet by hand to your theme’s source files directly. Most probably, you will need to add that to the
header.php file, but the exact file will depend on the structure of your theme.
Keep in mind, however, that this is a more invasive operation, and it can lead to some problems down the road. Particularly, if you ever update the theme, the code will go away and you’ll need to re-include it.
As for where to place the pixel code, here’s an excerpt from Facebook’s rulebook:
Copy and paste the pixel code into the bottom of the header section of your site, just above the tag. Install the base code on every page of your website.
That’s it! 🍾
With these simple steps, we’ve just managed to add Facebook pixel to WordPress!
As you can see, this is super-easy with the Blocksy theme. Plus, you get the added benefit of being able to add the pixel to select posts or pages only.
If you haven’t checked out Blocksy yet, give it a go here. The free version of the theme is one of the most functional and easy-to-use solutions of this type on the market!