Getting Started With Custom Audiences From Your Website (Deprecated)

Custom Audiences from your Website allows you to target your Facebook ads to audiences of people who have visited your website and remarket to people who have expressed interest in your products.

In this guide you will learn how to

How it Works

The Custom Audience pixel is activated every time someone opens a webpage where the code is installed. When the pixel is activated an event is sent to Facebook's servers with general information about the browsing session including page URLs. The events are then compared to a set of Audience rules the advertiser has created. If the event matches an Audience rule the person who visited the webpage is added to that Audience. These website Custom Audiences can later be targeted by ads.

To get started creating Custom Audiences from your Website you will need to complete three primary steps. They may be completed in any order but each is required before you can successfully use the product.

Install the Custom Audience pixel

The Custom Audience pixel is a small piece of javascript code that you copy and paste into your webpage. Installing this code into your website and verifying that it works is the first step in creating Custom Audiences from your website.

Follow these instructions to install the Custom Audience pixel on your website.

In order to follow these instructions you must have access to your web page's source code and be reasonably familiar with making changes to this source code. If you do not have access or are not comfortable making changes, send these instructions to your webmaster.

Step 1: Find your Custom Audience pixel.


In Ads Manager

a. Visit your Facebook Ads Manager at www.facebook.com/ads/manager. In the top navigation, Click Tools then Pixels.

b. Click Create a Pixel.

c. Enter a name for your pixel. There's only one pixel per ad account, so choose a name that represents your business.

d. Read and agree to the Custom Audience Pixel Terms of Service.

e. Click Create Pixel.

f. You can choose either to view the pixel code by clicking on 'Install Pixel' or click Email Pixel Code, type in that person's email address and click Send.


In Power Editor

a. Open Power Editor at www.facebook.com/ads/manage/powereditor. Download your account to Power Editor.

b. Click on Audiences.

c. From the Audiences page click the Create Audience button near the top left. From the dropdown menu click Custom Audience.

d. Click Custom Audience from your Website.

e. Read and agree to the Terms of Service. Click Create Audience to continue. Click 'View Custom Audience Pixel'.


Step 2: Select and then copy the entire pixel code.

The entire code is required in order to collect Custom Audiences from your website. The code begins with a <script> and ends with a </noscript> . When you copy the code be careful not to forget to copy a part or change anything.

Your code should look like this:

The code below is provided for example only. If you decide to use it make sure to change the Pixel ID 1234567890 to the Pixel ID from your own account. Otherwise it won't work.

<!-- Custom Audience Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
// Insert Your Custom Audience Pixel ID below. 
fbq('init', '<FB_PIXEL_ID>');
fbq('track', 'PageView');
</script>
<!-- Insert Your Custom Audience Pixel ID below. --> 
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=<FB_PIXEL_ID>&ev=PageView&noscript=1"
/></noscript>
<!-- End Custom Audience Pixel Code -->

If your code looks different than the code above you may be using an old version of the Custom Audience pixel. Don't worry, old versions still work but you should consider upgrading to take advantage of new features.

The code contains a pixel ID which is linked to your Facebook Ads account and is unique to that account (not your Facebook user account). The pixel code is the same for every audience you create. You only need to add one Custom Audience pixel to your entire website regardless of the number of audiences you create.

Step 3: Paste the Custom Audience pixel into every page of your website.

We recommend placing the code immediately before the closing </head> tag in your HTML. If your site has a global include file, such as a header.php, place the code there. Placing the code in the header isn't necessary, but will improve the quality of the events sent to Facebook.

Configure your Audience Rules

Once your pixel is installed you can shape the incoming events using Audience rules.

Step 1: Give your Audience a Name and Description

Choose a descriptive name that helps you identify the audience.

Step 2: Set a rule to shape your Audience

In order for a rule to match a page, that page must have the Custom Audience pixel implemented properly.

Match all Visitors

You can choose to match all pages to your website by selecting 'All website visitors' in the Audience rules builder interface. This setting will match anyone visiting any page on which your account's Custom Audience pixel is installed.

Match people visiting specific pages

You can match specific pages by selecting 'People visting specific pages'. Rules set in the Audience builder interface match pages. People that visit these matched pages are added to Audiences.

Rules are based on the common URL structure. You can shape these URL patterns through four conditions: contains any, doesn't contain, equals to, or is not equal to.

NameDescriptionExample

URL

A URL is the complete web address of your page. In most web browsers, the URL of a web page is displayed on top inside an address bar.

http://www.example.com/shoes/yellow

Contains Any

Matches any page that contains any of the provided keywords

/shoes would match both www.example.com/shoes and www.example.com/shoes?123

Doesn't Contain

Matches any page that does not contain any of the provided keywords

/pumps would match www.example.com/shoes but not www.example.com/pumps

Equals To

Matches any page that contains exactly the provided keywords but no others

www.example.com would match www.example.com but notwww.example.com/shoes

Is Not Equal To

Matches any page that does not exactly match the provided keywords

www.example.com/pumps would match www.example.com but not www.example.com/pumps

For example, say you have a website that contains the page www.example.com/shoes and a shopping cart at shop.example.com. You might consider the following rules:

  • To match any page, click on 'All Website Visitors'
  • To match the homepage www.example.com and not match any other pages, choose URL > Equals to > http://www.example.com. When you are using 'equals to', make sure you specify the complete URL address with http:// or https://
  • To match the shopping cart subdomain shop.example.com but not match the subdomain www.example.com, choose URL > Contains Any > shop.example.com
  • To match the page www.example.com/shoes/red?style=1234 and any page like it that contains the word shoes but not blue shoes, choose URL > Contains Any > shoes + URL > Doesn't Contain > blue

To add additional conditions click the "+" button

Step 3: Add a retention window

By default your Audience is set to expire after 30 days. That means that people who visit your matched pages are kept in the Audience for a maximum of 30 days. After 30 days from their first visit they are removed from the Audience. You can adjust the retention window from a minimum of 1 day to a maximum of 180 days.

Target your Audience with an Ad

The final step in using Custom Audience from your Website is to target your new Audiences with a Facebook ad. In order to complete this step you must have installed your Custom Audience pixel, configured your Audience rules, and waited until your website Custom Audience has reached an acceptable size.


In Ads Manager

  1. Opens Ads Manager create flow at www.facebook.com/ads/create
  2. Choose your advertising objective and proceed to the ads creation page.
  3. Scroll down to the Audience section.
  4. Click on the Custom Audience form field and enter the name of your new website Custom Audience.
  5. Finish setting up your ad and click Review Order.

Your website Custom Audience is now targeted in a Facebook ad.


In Power Editor

  1. Open Power Editor at www.facebook.com/ads/manage/powereditor/
  2. Click Create Ad.
  3. In the Audience section, under Custom Audiences, start typing in the name of your website Custom Audience. Your website Custom Audience will appear. Select it.
  4. Continue completing your ad.

Your website Custom Audience is now targetted in a Facebook ad.


Legacy Pixel Code

The following is legacy pixel code provided for those using older versions of Ads for Websites which provided the Custom Audiences Pixel:

    <!-- Custom Audience Pixel Code -->
<script>(function() {
  var _fbq = window._fbq || (window._fbq = []);
  if (!_fbq.loaded) {
    var fbds = document.createElement('script');
    fbds.async = true;
    fbds.src = '//connect.facebook.net/en_US/fbds.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(fbds, s);
    _fbq.loaded = true;
  }
  _fbq.push(['addPixelId', "1234567890"]);
})();
window._fbq = window._fbq || [];
window._fbq.push(["track", "PixelInitialized", {}]);
</script>
<noscript><img height="1" width="1" border="0" alt="" style="display:none" src="https://www.facebook.com/tr?id=1234567890&amp;ev=NoScript" /></noscript>

What's Next