Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Install Facebook Remarketing/Retargeting Pixel in WordPress

Are you looking into retargeting ads on Facebook? Do you want to install Facebook’s remarketing/retargeting pixel in WordPress? In this article, we will show you how to install Facebook remarketing/retargeting pixel in WordPress.

Adding Facebook Retargeting Pixel in WordPress

Why Use Facebook Retargeting Pixel to Boost Your Social Reach

Syed Balkhi, our founder and CEO, published a case study on how we boosted WPBeginner’s Facebook traffic by 332% in 2015. This sparked an overwhelming interest from our readers who wanted to know how they can do the same for their websites.

When you boost Facebook page posts using Facebook ads, you can select a wide range of target audience. Retargeting allows you to narrow your audience and get better results with less spending.

You can show your ads to people who are already interested in your website. These people are much more likely to respond to your boosted posts and advertisements on Facebook.

What is a Facebook Retargeting Pixel?

Have you noticed that after you visit a website, you start seeing their ads on Facebook? This is called retargeting or remarketing.

Those websites use Facebook’s retargeting technology, commonly known as Facebook Pixel.

The retargeting pixel does not add anything visible on your website. It simply sends a browser cookie to your visitors.

This allows Facebook to retarget users visiting your website on Facebook.

Let’s take a look at how you can add a Facebook retargeting pixel to your WordPress site.

Creating a Facebook Retargeting Pixel

To make it easy, we have created a video tutorial on how to install a WordPress plugin that you can watch below.

Subscribe to WPBeginner

However if you just want to follow text-instructions, then you can follow our step by step tutorial on how to How to Install Facebook’s Retargeting Pixel in WordPress.

First, you need to login to your Facebook account and visit Ads Manager. Next, click on Tools » Pixels to create your Facebook pixel.

Creating Facebook Pixel

When you click on the create pixel button, it will show you a popup. Simply enter a name for your pixel which can be a name of your business or product, and then press the create pixel button to continue.

Enter a name for Facebook Pixel

You will see a success message with the unique ID of your pixel.

If someone else manages the technical things on your website, then you can email them the pixel code. Otherwise, click on ‘Install Pixel Now’ button to install it yourself.

Facebook Pixel is ready for installation

Facebook will now show you the Pixel code that you need to install on your WordPress site. Simply copy the pixel code, and we will show you how to install it in WordPress.

Copy the Facebook Pixel code

Installing Facebook Pixel in WordPress

You need to add the Facebook Pixel code just before the </head> in your WordPress theme.

The easiest way to do this is by using the Insert Headers and Footers plugin. After installing and activating the plugin, you need to go to the Settings » Insert Headers and Footers page.

Adding Facebook pixel code using insert headers and footers plugin in WordPress

You can paste your Facebook Pixel code in the header section and click on the save button to store your changes. See our guide on how to add header and footer code in WordPress for detailed instructions.

That’s all, you have successfully installed Facebook Pixel on your WordPress website.

Bonus Step: Creating Custom Audiences Using Facebook Pixel

Now that you have successfully installed Facebook Pixel on your WordPress site. The next step is to create custom audiences for your retargeting campaigns on Facebook.

Custom Audiences allow you to target users you already know for your Facebook ads. These users can be your website visitors, users who like your page, or users who signed up for your mailing list.

Here is how you can create custom audiences in Facebook.

Simply visit Facebook Ads Manager dashboard and go to Tools » Audiences section.

Facebook custom audiences

This will bring up a popup where you need to choose the kind of audience you want to target on Facebook.

You can choose a customer list, website traffic, or app activity. For the sake of this tutorial, we are going to choose website traffic.

Choose a Type of Custom Audience

Now Facebook will ask you which website audience you want to target. You can choose all website visitors, people who visit specific pages, people who don’t visit specific pages, and so on. You can also create custom combinations.

Selecting audience from website traffic

Next you need to choose a duration in number of days. Lastly, you need to provide an audience name. Use something that helps you easily identify this audience in your insights.

Once you are done, click on the create audience button to finish creating your first custom audience.

Repeat the process to create more custom audiences by Facebook retargeting.

Showing Your Ads to Custom Audiences Using Facebook Retargeting Pixel

The real fun begins with engaging your custom audiences by using Facebook ads.

Start by creating a new ad in Facebook. You can run different kind of ads for different objectives. Like boosting your page posts, sending traffic to your website, increase conversion, and so on.

Depending on what objective you choose, you will be able to select the target audience at some point during the ad creation.

In the same audience selection, Facebook will show you custom audience, and you can select it to be targeted with your ad campaign.

Retargeting custom audience on Facebook

We hope this article helped you install Facebook remarketing/retargeting pixel in WordPress. You may also want to see our guide on how to install and setup Facebook comments in WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

44 CommentsLeave a Reply

  1. Can you make an updated version of this? Now FB has a partners integration option. I have tried this version of doing (downloading a plugin) and I’ve tried their partners way of doing it and neither way is working for me.

  2. Thank you for the post and even though it does need updating since Facebook has changed the links and process, I finally added the pixel to my website. Note with the improvement in the WordPress Customizer, a plugin is no longer needed to add the pixel code above the /head.

    • Thank you for your feedback and we still recommend the plugin to ensure it is included on every page on the site :)


  3. I was using the Facebook for woocommerce plugin that automatically sets up a Facebook pixel on a particular website.

    I started a new hosting account and redirected my domain name servers to point to the new hosting account.

    My question is, since I changed my hosting account and started building the site from scratch, will the pixel still be attatched to my domain?

    • Sadly, for that plugin, you would need to check with the plugin’s support for how they handle a change like that


  4. Well I think it’s done right, thanks WpBeginner! Still not sure what I should be doing with the second bit of code from Facebook in order to track people who have gone to one particular page. I clicked around for over 2 hours on FB then my wp site, then gave up as usual.

    I’m not even sure how this works, where does the headers and footers plugin put the code, in to every page? Do I just add the second bit of FB code beneath this? it needs to go after the . Does it go in the page template? Posts template? I’m lost as usual, until FB make this easier I’m not going to bother. Selecting your audiences, demographics, countries, Events? and all that, it’s just too overwhelming for most business owners. Those who have money will survive online, they can pay someone else to do it, one-man businesses like mine will eventually disappear. I can’t make any money wasting time on things like this so it just gets worse. Already slipped off the first page of Google after 14 years on there, all down hill from here I’m afraid, time to do something else.

  5. Thank you! I followed the instructions. I already had headers and footers installed and there was already code in the header section so I put this above it. Is that OK?



      • Ya, there is no Problem in doing So. It is Completely Fine this only a Code.
        This Code load each time when your site page run. there is no problem in that OK. Both Code run and send the Respected data back to FB and Google by their Respective code.

  6. Hi there. There is one question that I have on the FB pixel I just can’t seem to find an answer for anywhere. Shopify has an app called Trackify that allows you to segment the events, per product for example, and in doing so allows you to super target people who have purchased a particular product without setting up custom events. Is there a similar plugin for WordPress. Please if you could help that would be great! I am at my wits end with searching for a solution.

  7. Thank you most kindly for this tutorial. I really did not how how to use the FB pixel. Thanks again.

  8. I’ve installed the pixel using the plugin.
    Will the pixel automatically be place on every page?

  9. It seems like Facebook has changed some of the details for doing this since this post was written. They now have a new pixel which also includes having to copy event code. How/where do we do this within the context of this article and plugin?

  10. How do you install the pixel to fire on page load given the plugin constraint?

    I’ll clarify- Facebook states that if you want an event to fire on page load the code for that specific event has to be pasted BELOW the head tag.

    The plugin in you recommend, as well as all the others I’ve seen available for WP, don’t address this issue.


  11. Is it also possible to add the code on the footer instead in the header portion? usually if it’s for tracking purposes better implementation would be on the footer part, your know for SEO purposes.

  12. I went ahead and installed the pixel because i wanted more visits to my music site. I started filling in the remarketing stuff in FB, then I came to the part about paying! I didn’t realise I had to pay so I’ve uninstalled the remarketing pixel in WP and delete everything in FB that I’d filled out. I hope I don’t start getting demands for money. Maybe you could add a note to your article that there will be payment involved in FB marketing. I guess I should have realised. :-(

    • You didn’t think you had to pay for marketing or advertising? Where have you been for the past one thousand years?

  13. Great article! Thanks

    I use wordpress on mys ite – I’ve managed to install the facebook pixel using the “insert headers and footers app” and facebook says it is successfully installed

    in wordpress, what’s the best way to install a standard event code? I have a “thank you” page that I would like to use as my conversion referecence – the thank you page appears after the viewer has submitted a form


    • I have also successfully installed the facebook pixel code through insert headers and footers by wpbeginner, now I want to know how to add standard event codes. Can anyone teach us how to? Big thanks to WPBeginner for this

  14. I added the FB retargeting pixel about a month or so ago to my WP site, and the Facebook Pixel Helper showed it was installed and working. Now I “hear” there is a new Facebook Pixel, AND my Facebook Pixel Helper shows “there are no Facebook pixels” on my site.

    The article I read goes all over the world and back about everything I don’t want to know about. All I want to know is how to replace the pixel. You are a trusted source so I thought I would ask … is there a new pixel out? And can I add it (or replace the old one) as easily as it was to add it the first time (with a plugin), or will it require manually adding code to each page?

  15. How do we add other rules, like these Search fbq(‘track’, ‘Search’);
    Add to cart fbq(‘track’, ‘AddToCart’);
    Add to wishlist fbq(‘track’, ‘AddToWishlist’);
    do we simply add it to the code?

  16. I need to re-copy the Facebook pixel if I add standard/custom events for Conversion Tracking, to paste the new one into the website.

    Does that mean I only have PageView data up until I update the code on the website, or does any type of data backtrack and becomes available as long as I had the original/basic Pixel installed?

  17. Hi,

    I have done this and the Facebook pixel is tracking. However I am using the sign up form as well with the mailchimp API and I added the Lead and Complete registration aspects to the pixel in the header. They are firing as the chrome addon shows that however the sign up form isnt triggering as a sign up or registration complete. I am not sure if I am explain my problem well. So in business manage and the pixel I can see people visiting my site. But when they sign up the value for lead or complete registration is still 0. Any ideas why this occurs? I used the old FB conversion pixel and that was fine just this new one is so annoying!


  18. Wow! Thank you very much for writing this post and recording a video to help your audience implement this important tool.

  19. Hi,

    I need to add ” Facebook Pixel Code ” in my wordpress site.

    May I know if this plugin suitable for it.


  20. Dear author, I have a question on the “Add conversion tracking” feature. Like you instructed, if we place the Facebook pixel into the header section of the plugin, that piece of code will be on every page. But if I have a conversion page, how do I single out that particular page and add in a custom event such as fbq(‘track’, ‘Lead’); to the middle of the Facebook pixel?

    Usually with WordPress or other CMS, once something is in the header, it is on every page. How do we then put up something different for a particular page?


  21. Great article, Can I use this feature right away or first I have to buy facebook ad campaign. I means paid Facebook advertising.

    Thanks alot syed balkhi for a cool post.

  22. hello
    i want to ask about this

    is this using facebook ads first. become subscriber user facebook ads

    thank you,

  23. This is perfect. I am starting to experiment on Facebook Ads.

    On other note, is there a way to tell where are facebook visitors coming from? Sometimes I get a load of new user and have no idea who shared a link to my website.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.