How to Add the Facebook Retargeting Pixel to Your Website

Has this ever happened to you? You visit the website of a local business only to discover an ad for that exact location in your Facebook feed 20 minutes later. Welcome to the world of Retargeting Ads.

What is Retargeting Marketing

Retargeting is the process of displaying ads to people who have already come in contact with your brand, usually by visiting your website or clicking on one of your PPC ads (example: Google AdWords).

Retargeting can be very efficient because it only targets users that have already visited your website at least once and have been exposed to your brand. These visitors are more likely interested in your product or service and are easier to convert into paying customers.

Before we begin: Some people use Retargeting and Remarketing as synonyms, even though there is a difference between the two. Even Facebook uses the word Remarketing when describing the benefits of using Facebook Pixel. I consider that the proper term for this process is Retargeting.

How does Retargeting work

Usually a small piece of JavaScript code is added to the website for which you want to use retargeting. This code will place a HTTP cookie (what are cookies?) in every visitor’s browser, adding them to an audience list.

It is important to note that you will not have direct access to personally identifiable information about the people on the list. You will not be able to see who is on it, just an estimated number and some demographics data, like gender, age, etc.

Facebook Retargeting Pixel

Facebook provides website administrators and advertisers with a way to build a custom audience list of logged-in Facebook users that have visited your website.

The Facebook pixel is a piece of JavaScript code for your website that enables you to measure, optimize and build audiences for your ad campaigns. Using the Facebook pixel, you can leverage the actions people take on your website across devices to inform more effective Facebook advertising campaigns.

How to Create a Facebook Retargeting Pixel

1. Go to Facebook Ads Manager > Assets > Pixels.

hermes-facebook-pixel-1

2. Click the “Create a Pixel” button at the bottom of the page.

hermes-facebook-pixel-2

3. Choose an intuitive name for the pixel, but it doesn’t make any difference.

hermes-facebook-pixel-3

4. Click the “Install Pixel Now” button.

hermes-facebook-pixel-4

5. We finally get the full code that we have to add somewhere in the header of our website, somewhere between the <head> and </head> tags.

hermes-facebook-pixel-5

Currently you can create only one Facebook Pixel under the same account, but you can use the same Facebook Pixel to track multiple websites. Simply create separate Audiences for each website, but the Pixel code will be the same across all domains.

How to Add the Facebook Pixel code to a WordPress website

Our objective is to add the Facebook Pixel code somewhere between the <head> and </head> tags. There are multiple ways of achieving that in WordPress.

1. Manually add the code to our theme’s header template file.

Go to Dashboard > Appearance > Editor and open header.php file. Find the </head> tag and add the code BEFORE it. Save the file and you are done.

hermes-facebook-pixel-8

The Good

  • This method should work for most WordPress website owners and is pretty straightforward.
  • This method is the quickest to accomplish and doesn’t require installing third-party plugins that could affect general performance of the website.

The Bad

  • This method will NOT work for websites hosted on the WordPress.com network, as there is no possibility to edit the theme’s files.
  • This method will NOT work for websites that are part of a WordPress multisite environment for the same reason as above.
  • This method will NOT work for self-hosted WordPress websites that have implemented the recommended security hardening measures. One of the recommended measures is to add this code to wp-config.php, which will prevent anyone (even the admin) from editing any plugin/theme files directly from the Dashboard > Appearance > Editor page. define('DISALLOW_FILE_EDIT', true);
  • In case you ever decide to change the active theme on the website, you will have to remember to copy the code from the old theme to the new theme. Yet another thing to remember.

2. Use a third-party plugin that adds custom code to the header and footer sections of a website.

You can install, active and use the following plugin: https://wordpress.org/plugins/header-footer/.

hermes-facebook-pixel-9

The Good

  • Should work on all WordPress websites, unless there’s some crazy incompatibility with a custom theme or another plugin.

The Bad

  • An extra plugin to have installed and activated. Every extra third-party plugin potentially can negatively impact the website performance (even if by a fraction of a second). Also there’s always the security aspect, as outdated or poorly written plugins can pose a real security threat.

3. Adding the code via the Theme Options page of a custom WordPress theme.

Some theme developers include a Theme Options page into their WordPress themes. Many of these Theme Options pages contain a section where you can add custom code to the header and footer sections of the theme.

This is how to add the code if you are using a WordPress theme by HermesThemes.

hermes-facebook-pixel-6

This is how to add the code if you are using a WordPress theme by WPZOOM.

hermes-facebook-pixel-7

The Good

  • You don’t have to install a plugin or directly edit a theme file.
  • You can also add other code in the same location (Google Analytics tracking code).

The Bad

  • If you change the active theme then you will have to re-apply the code using one of these methods.
  • Not all themes come with a Theme Options page that includes this feature.

Assuming that we have successfully added the code to our website, let’s now define a Custom Audience using the data from this pixel.

Creating a Custom Audience using the Facebook Retargeting Pixel

Go to the Facebook Ads Manager > Assets > Pixels page and click the Create Audience button.

hermes-facebook-pixel-10hermes-facebook-pixel-11

You can define custom filters and conditions for each custom audience, and you can have multiple custom audiences.

For example you can have an audience for all the traffic that your website gets, a custom audience for visitors that visit your product pages, an audience that opened your Pricing page and an audience for people that got to the final stage of your shopping cart funnel but failed to complete a purchase.

Please note that you cannot change an audience’s filters and conditions (type) after creating it, but you can easily delete an audience if you made a mistake.

Creating a Facebook Ad targeted at a Custom Audience

Now that our Facebook Pixel is set up and we have created a (or multiple) custom audience(s), we can now create Facebook Ads targeted specifically at our custom audience(s). You can have the same ad targeted at one or multiple audiences.

hermes-facebook-pixel-12

Practical Uses of Retargeting for Hotels, Inns, B&Bs, etc.

Hotel websites can benefit a lot from retargeting, as people generally don’t go to hotel websites without a reason. Every visitor is a potential customer, now or in the future.

Building a custom Facebook audience for your website visitors is a great way to try and convert them into paying customers.

For example you could show an Ad to this audience with a special offer or a coupon code if they take a certain action. Or you could target an ad at people that visited your Elopements page and looked at the Honeymoon Suite.

There are numerous possibilities to make some extra effort and really focus on specific ads. This is especially attractive during pre-season and low season, when you should have some extra time on your hands.

Final Words about Facebook Retargeting

Retargeting is a marketing process with a very decent ROI for most business owners, especially when you are in a very competitive niche. You could be paying over $3 per click via Google AdWords, but then retarget these visitors via Facebook with $0.3-$0.5 per click.

You can also boost your Facebook Page posts and target it mostly at your custom audience, which could get better results than simply targeting people that liked your page some years ago.

However as the saying goes – with great power comes great responsibility. Some studies have argued that for some niches retargeting could do more harm than good. One such study found out that the older your audience is, the less likely it is they will be impressed by your retargeting efforts. However young people under 30 are perfectly fine with this process.

Share your thoughts

Have you already tried Facebook Retargeting (or other types of retargeting marketing)? Were you pleased with the results or not? Share your experience in the comments section below.

Author: Dumitru Brinzan

Founder and WordPress developer at HermesThemes.
With over 7 years of experience in the hospitality industry, it is my strong belief that WordPress brings unprecedented opportunities for independent hotels, B&Bs and inns.
Over a thousand of amazing properties worldwide use our Hotel WordPress Themes on their websites.