Analytics

Using Google Tag Manager to Create Custom Facebook Audiences

If you’re looking for new customers, targeting people that know you is the way to go.

This is why email is so effective and has a high ROI.

But it’s not the only ‘permission-based marketing’ option available to you.

Ever since the launch of Facebook advertising, marketers have designed ads and campaigns specifically for people with whom they have some connection.

The feature that makes this possible is custom audiences.

I’m not talking about using targeting options like age, location, education, or income level. Ho hum. You’ve heard about that a million times.

Rather, this technique targets people that have engaged with your brand at some level.

The result?

Ad campaigns that give you the most bang for your buck.

Throw Google Tag Manager into the mix? There is potential for an insane level of control.

In this post, I’ll show you how to combine Facebook pixel with GTM for some ninja-level targeting.

What Are Custom Audiences (And Why You Should Care)

Not sure what a custom audience is?

Basically, it’s a feature you can use to inform Facebook which users to expose your ads to.

Facebook first introduced custom audiences back in 2012.

At that time, marketers could create a custom audience only if they provided one or more of the following data points about their target audience.

  • Phone numbers
  • Email addresses
  • Facebook user IDs
what is custom audience

Facebook would use this information to ensure your ads or sponsored content only reached these people and no one else.

While effective, this approach had one flaw.

You needed an existing database full of viable leads.

If you just launched your business, you’d have to wait around to build a database before you could create a custom audience.

Fortunately, it wasn’t long until Facebook identified this limitation and introduced tracking pixels (now known as Facebook pixel) along with other options for creating custom audiences.

Pixels changed the landscape completely.

Marketers could now create custom audiences based on who visited their website or the action(s) a visitor performed.

facebook pixel website traffic

Nowadays, simply installing a pixel on your site and ticking a box is all it takes to create a custom audience to remarket to.

Ever wonder why ads from that e-commerce store you were on last week is following you around on Facebook?

That’s Facebook pixel at work.

A pixel is simply a piece of Javascript that you add to your site’s code.

Here’s what it looks like:

facebook pixel code

This is also referred to as the pixel base code.

If you add this code to your site, you’ll only be able to track (and remarket) to incoming visitors.

Note: The pixel code has to be placed within your site’s HTML.

where to place pixel code

Here’s how pixel helps you create a custom audience:

When someone visits your page, pixel will inform Facebook to log a visit from that user.

If you decide to add this visitor to a custom audience list, only then will they be exposed to your ad when they next log into Facebook.

But what if you want to show your ad only if someone performs a desired action?

For that, you’ll need to add an extra line of script known as the event code.

Officially, there are 9 standard actions that you can track with Facebook pixel. These actions are spread across a user’s purchase journey.

fb standard actions

This information can be invaluable to creating a customized campaign that speaks to that specific customer.

What if you could remind that lead about that amazing raincoat they were browsing on your site last week?

Show them the exact one again, and maybe a similar or complementary product, the next time they visit Facebook and you’ll convert significantly more sales than generic ads to a broader audience.

Getting Started With The Basics Of Facebook Pixel

Now that you know about pixels, let’s review how to make them work for you.

To create a pixel, head over to Facebook Ads Manager and click on create ad. You should see a dashboard from where you can manage your entire ad account.

Click on the drop-down menu on the left side and select the ‘pixel’ option.

fb ads manager

You’ll be taken to another page that looks like this.

create a pixel

Hit ‘create a pixel’ to get the ball rolling.

The very first thing Facebook will ask you to do is name your pixel.

Pick your name carefully because you can only create one pixel per ad account. The name should best represent what you hope to accomplish with that pixel.

For example, if you’re only tracking visitors, you might name it “visitors to [your brand name].”

That’s all there is to it!

Once you name your pixel, Facebook will give you the code to add to your site.

Remember this is the base code that you need to add inside your site’s HTML code (<head> and </head> tags).

For tracking events, you’ll have to do a bit more to get pixel working properly.

There are two options available to you.

The first option is to use Facebook’s 9 predefined standard events that I talked about earlier.

Each of these has a unique ‘event code’ (refer to screenshot from the previous section) that you must add in addition to the pixel base code.

Here’s how it looks:

pixel event code

Notice that the event code is placed outside the HTML in this case.

This has to do with how Facebook categorizes actions.

In some cases, the event code has to be placed inside your HTML. Other times, it must be placed outside.

How do you figure out the right location for your event code?

Ask yourself whether an action leads to a new page loading on your site.

When someone submits an opt-in form, they’re usually led to a different page (a confirmation or thank you page, for example).

But if they’re just adding an item to their cart, this doesn’t happen.

Facebook defines these scenarios as on-page load and inline action.

  • On-page load is when an action triggers a new page to load
  • Inline action is when an action does not trigger a new URL to load

The event code must be always be placed outside the HTML for on-page loads.

For inline actions like “add to cart,” you can place the event code inside your HTML.

inline action event code

If you’d like more control than the standard 9 events, Facebook does give you some flexibility with custom conversion events.

custom conversion events

Surprisingly, custom conversions let you track events only using the base code.

You don’t have to worry about event codes or whether an action triggers a new page load or not.

How is this possible?

Facebook has a workaround in which it asks you to define the URL triggered for the action you wish to track.custom conversion pixel

This is useful if you have the same type of action trigger different pages.

For example, let’s say you have 3 different lead forms and each triggers a different thank you page.

Using the standard event code means pixel would bundle everyone who submitted an opt-in form together.

But what if you wanted to show ads based on which opt-in form a user submitted (which lead magnet struck their interest enough for them to “bite”)?

With custom conversions, you can create up to 40 ‘rules’ that let you separate people into different audience groups regardless of if they performed the same action.

This makes it easy to create ads that are relevant to each individual/specific group.

Where Standard Options Fall Short: Using Advanced Custom Audiences

While pixels are useful, it didn’t take marketers long to discover its limitations.

The complaint echoed repeatedly amongst marketers was their inability to create custom audiences using engagement levels.

What do I mean by engagement?

Let’s look at an example.

Say you receive two visitors to your site. One leaves within 10 seconds while the other spends a minimum of 2 minutes per visit over 3 visits.

Which person is more likely to be actually engaged with your brand?

The latter, of course.

Unfortunately, if you were using basic pixel settings, both users would be entered into your remarketing audience.

This may equate to wasted money on impressions or clicks that don’t convert.

In 2016, Facebook released upgrades to its pixel platform to specifically tackle this issue.

With advanced custom audiences, marketers could now create custom combinations that gave them with more granular control of who saw their ads.

To access these options, select ‘custom combination’ in pixel and make sure ‘advanced mode’ is turned on.

custom combination

Here are the added parameters you’ll find in the new advanced options.

  • Frequency

Frequency lets you tell Facebook how many times a visitor must land on your site (or perform an action) before they are placed in the remarketing pool.

  • Dynamic date

This option gives you the ability to target visitors who visit your page repeatedly over a defined period of time.

  • Aggregate value

Aggregate value simply means including (or excluding) visitors based on the total amount of time they spend on your page.

  • Devices

If you’re looking to remarket to users on certain devices (example – pc vs. mobile), you can use the device option to set up inclusion or exclusion rules.

advanced targeting options

These new options give marketers the ability to be more laser-focused with their targeting.

But we can get even more detailed!

How Google Tag Manager Fits Into The Picture

Despite Facebook’s push to prevent undesirable users in remarketing audiences, advanced custom audiences still had some leakage.

How?

It has to do with how pixel informs Facebook to record data.

When a user clicks a link, the server is immediately put to work to load that page. This includes the pixel code inside the HTML.

As you’ll recall, it’s difficult to eliminate accidental hits as pixels are fired instantly. Sure, you can use advanced options to filter them out but you can’t always rely on that fix.

Nor does it work in every scenario.

For example, let’s say you’re trying to assign two different ads to visitors based on the behavior they display on your page.

The first ad is reserved for visitors who scroll down at least half of your page and spend a minimum of 30 seconds on your page. This is to eliminate those who skim and don’t engage.

The other ad is reserved for visitors who scroll to the end and spend at least 2 minutes on page.

Without Google Tag Manager (GTM), isolating these visitors into separate pools is difficult.

So how does GTM help?

It lets you define when a pixel is triggered or fired. This gives you absolute control over when Facebook adds someone to a remarketing audience.

In case you’re not familiar with GTM, here’s a refresher:

It’s an intermediary service meant to make the lives of a developer and marketer easier.

It lets marketers create, update, and manage tags or snippets of code (like pixel) on a web page using a graphical interface.

Developers just have to perform a one-time installation of the GTM code on the desired page.

google tag manager

GTM removes the bottleneck of marketers waiting on developers to make modifications.

Once you have GTM on your page, here’s how to link your pixel with it:

In the create pixel tab (under set up), select ‘use an integration or tag manager.’

gtm install pixel code

Pick GTM and click install.

You can now start adding custom pixels and publish them live on your site or keep them in a draft for later.

gtm pixel code

Putting GTM To Work For Laser-level Control

With GTM up and running, defining the scenarios when a pixel is triggered is your next step.

Naturally, you want a pixel to fire only when it makes business sense. This may mean that the pixel does not load as soon as a user clicks your link – like we’ve seen up to now.

How do you delay a pixel’s activation?

Use the preinstalled trigger options in GTM. A few examples of these triggers include time on page and scroll-depth.

You can use them to create unique pixel trigger conditions.

For example, let’s say you want only engaged users in your remarketing pool.

First, define what engagement means for you. Perhaps you define it as any user who spends 45 seconds or more on your page.

Select the time on page trigger and input 45 seconds.

By doing this, you’re telling GTM to fire a pixel only when this condition is met.

And this is only touching the surface of what is possible!

GTM can also store data in what is known as a data layer. This lets you combine multiple triggers to create a single condition of when a pixel is triggered.

Let’s build on our engaged page visit example.

Let’s say you decide to add a new condition of 50% scroll-depth on top of the 45 seconds spent on site to redefine what an engaged visitor looks like.

As both conditions are unlikely to be met simultaneously, GTM will record and store whichever trigger occurs first the data layer.

It will then wait for the second condition to be met.

In addition to triggers, GTM also lets you create custom event pixels.

These expand on the 9 standard event options from earlier. With custom event pixels, the limit of what is possible is your imagination.

You can program a pixel to fire for very specific conditions like:

  • When a user is logged in
  • When a transaction greater than $100 is made
gtm triggers

Setting this all up can get technical, so I recommend having a developer help you out with this.

But if you’re doing it yourself, make sure to avoid this one, big mistake:

Don’t turn off Facebook’s initialization pixel (the one that is triggered instantly). It must still fire regardless of whether you’ve defined a custom pixel.

If the initialization pixel doesn’t fire, Facebook won’t log any data from your custom pixel.

Why?

Because it has no record of a visitor ever arriving on your page.

If you’re managing custom multiple pixels, use the tag sequencing feature.

It helps you to manage when and where your pixels should fire. Remember to program the initialization pixel to fire before your custom pixels.

tag sequencing

And make sure to select the option that tells the initialization pixel to fire only once.

Otherwise, you’ll have an inflated number of page views.

This whole process may seem challenging at first (and it can be) but don’t be deterred.

Once you find your way around this system, you’ll find the time invested in learning this process worth your trouble.

You’ll be able to use Facebook marketing in the most effective way possible: instead of disruptive ads to disinterested viewers, your ads will be gentle reminders to nurture interested leads into customers.

Conclusion

There’s no doubting the power of custom audiences on Facebook.

Not only can you use it choose who to market to on your own terms but also define what that audience looks like.

If you’re looking for campaigns that produce results, it’s time to integrate Google Tag Manager with Facebook pixel.