How to target referral traffic using Facebook

17. 9. 2019

With 2.4 billion monthly active users, Facebook has the largest social media platform in the world. Add in the ability to segment and target specific groups of users with ads, and you can see why advertising on Facebook is so effective. 

One way to select your audience is to target your website traffic. This could be an effective way to reach people that are already familiar with your brand. With that said, this could still be a very large audience. Not only that, different website visitors might have different needs or selling points depending on the way in which they came to be on your site.

When you target your website traffic by the referral source, you can narrow the audience down even further. With this option, you can target your website visitors by different search engines, social media sites or wherever they may have been referred from.

For those looking to target Facebook ads by the referral source, you will need to create and install a Facebook pixel for your website. After that, you can follow one of these two methods.

Filtering with Facebook Analytics

The first method is to create a filter from your Facebook Analytics page. Once you create the filter, you can then use it to build a custom audience from the desired referral source.

  1. Go to your Facebook Analytics page and select Add Filter from the top of the page.
  2. Select Create new filter and choose Web Parameters.
  3. Go to referrer domain and choose contains and then add the domain of the referrer you wish to track. 
  4. Give the filter a name and click on Save Filter.

With the filter set up, your Facebook pixel will start tracking website traffic that came from that referral source. From there, all you have to do is create a custom audience using the filtered traffic. 

Altering Your Pixel Code

If you have trouble setting it up through Facebook Analytics, you can alter the pixel code to start tracking referrer traffic. To start the process, you will need to access the header code of your website.

  1. In the Facebook pixel code, look for a section that reads: fbq(‘track’, ‘PageView’);
  2. Input , {referrer: document.referrer} after ‘PageView’ and before the close parenthesis.

With the code altered, Facebook will start tracking traffic by different referrers. The next step is to create a custom audience based on referrer traffic. 

To create your custom audience, select PageView from the events section of your pixel. After that, select Refine by and then choose URL/Parameter. From there, you select referrer and contains and then enter the domain of the referrer you want to create an audience for.

If you can identify trends based on referral traffic, you can then use this information to create ads that speak to the wants, needs or interests of this audience. As an example, you might notice visitors from a specific referral source always go to a specific page, you can then develop content that will move them to the next step of the buyer’s journey.

It does take some time to set up, but targeting by referral source can be a great way to reach a specific audience and serve them ads that are more relevant. As an alternative to using Facebook Analytics or manually altering the pixel code, you might be able to find a Facebook pixel manager plugin that you can add to your website.


Rae is a graduate of Tufts University with a combined International Relations and Chinese degree. After spending time living and working abroad in China, she returned to NYC to pursue her career and continue curating quality content. Rae is passionate about travel, food, and writing (of course).


Latest posts

Launch of We Speak Digital

The current pandemic made many businesses start offering their products or services online which only surged the need for digital marketing skills in the Middle East. Dubai-based platform We Speak Digital was launched to support...