×

How to Delay Meta Pixel with Google Tag Manager (Facebook Pixel)

Julian Juenemann

Last Modified on July 12, 2024

In this guide, we’ll show you how to build higher-quality audiences in your Meta Ads by delaying your Meta Pixel and eliminating bounced users from your audience.

This tutorial will explain:

How to Delay Meta Pixel with Google Tag Manager (Summarized)

  1. Create Base Meta Pixel Tag:
    • Go to GTM, click on Tags, then New.
    • Select Custom HTML and name it appropriately (e.g., CHTML – Facebook – Base Pixel).
    • Copy the Meta Pixel code from Meta Events Manager and paste it into the HTML field.
    • Set the trigger to All Pages and save.
  2. Create Timer Trigger:
    • In GTM, click on Triggers, then New.
    • Select Timer trigger type, set Interval to 5000 milliseconds and Limit to 1.
    • Set conditions to *Page Path matches RegEx . **, name the trigger, and save.
  3. Build Custom HTML Meta Tag for Timer Event:
    • Go to Tags, then New.
    • Name it (e.g., CHTML – Facebook – 5 Seconds), select Custom HTML, and paste:
      <script>
      fbq('trackCustom','5 Seconds');
      </script>
    • Attach the five-second timer trigger and save.
  4. Test Tags:
    • Use GTM Preview mode to ensure both tags fire correctly.
    • Use Meta Pixel Helper to verify events in Meta Events Manager.
  5. Set Tag Firing Priority:
    • For the base Meta Pixel tag, set Tag Firing Priority to a value greater than zero under Advanced Settings.
    • Select Once per event in Tag Firing Options and save.
  6. Create Meta Audience:
    • In Meta Events Manager, click Create Audience, select your Meta Ads account, and choose the appropriate pixel.
    • Create an audience of users tracked by the five-second event and set the duration.
    • Name the audience and create it.

Let’s dive into each of the steps!

Why Should You Delay Meta Pixel?

Delaying the Meta Pixel from firing immediately when a user enters your website will filter out any user who isn’t interested in what you have to offer.

Sometimes, users click on links accidentally or click a link, thinking it contains different content than it does. These users typically leave the website immediately (we call this a bounce).

That is fine — not everyone on the internet is part of your intended audience. However, it could be an issue if these users become part of your targeted audience for marketing campaigns.

These users are not promising leads. It could be a waste of your resources to target them. Instead, focus your efforts on users genuinely interested in your website or business.

If you want to optimize your audience for retargeting purposes, you might want to focus on users who have been on your website for more than a few seconds.

We can implement such a delay with the help of Google Tag Manager and create a Meta audience of people who have stayed at least five seconds on your webpage.

If you delay Meta Pixels, it will give you a better quality audience by excluding those who have clicked on a link by mistake or just closed the page immediately and didn’t have the chance to even look at the page.

Then, you should hopefully get better results by advertising to a better-quality audience.

🚨 Note: If you use The Meta Pixel and haven’t integrated Google Tag Manager yet, check out our Meta Pixel Tracking with GTM guide.

Creating Your Base Meta Tag

Let’s begin by creating our base Meta Tag. This Tag will load the Meta Pixel library so your pixel can record other Meta events.

We will create a new custom HTML tag in Google Tag Manager.

To create a new Tag, click on Tags, then New.

Create a new Tag in GTM

Make sure to give your Tag an informative name. I like to use CHTML for “custom HTML” to describe the Tag type, then the tool and the scope or function of the Tag. I’ve named this Tag CHTML – Facebook – Base Pixel.

Name new GTM Tag CHTML - Facebook - Base Pixel

Since there isn’t an official integration for Meta Pixel Tags, we’ll make a custom one using the Custom HTML tag type.

Select the Custom HTML Tag type

Next, go into your Meta Events Manager account on a separate tab and grab your unique pixel code. (You can find it under Set UpInstall Pixel Manually add pixel code to website.) You can click on the code box to copy the whole snippet.

Copy the pixel code from the Meta Pixel by clicking on the code field

Then, paste this pixel code into the HTML field of your new Tag. 

Paste the pixel code from the Meta Pixel into the HTML field of your new Tag

Since we’ll need this base Tag to fire first to track any other Meta events, we’ll want it to fire on all pages across our website.

To do this, we’ll scroll down and click anywhere in the Triggering field, then select the All Pages trigger for this Tag.

Select All Pages trigger for Base Meta Pixel Tag

Finally, click Save. We’re almost done with this step, so let’s test our Tag to ensure it’s working correctly.

Testing Your Base Pixel Tag

Click Preview to enter Google Tag Manager’s preview and debug mode.

Enter GTM Preview mode by clicking Preview button on dashboard

While in preview mode, navigate around your website. If everything is implemented correctly, your CHTML – Facebook – Base Pixel Tag should fire on each webpage. 

Base Meta Pixel Tag firing on the website shown in GTM preview console

I also like to use a browser extension called the Meta Pixel Helper, which shows here that a PageView event has fired. This is the Tag we just installed, so we know that the Tag is firing correctly and will be sent to our Meta Ads account.

Meta Pixel Helper browser extension showing that PageView event has fired

Creating a Meta Event that Fires 5 Seconds After Page Load

Now that we have a base Tag that will load our Meta Pixel library, we can create more customized event Tags to collect better data.

Next, let’s create a custom event for this Meta Pixel that fires five seconds after the page loads. It accomplishes our goal of tracking only users interested in our website and excluding users who bounce.

There are two main steps to this process.

First, we’ll create a timer trigger that will wait five seconds before firing our Tag. 

Second, we’ll need to build a new custom HTML Tag that will track a specific Meta event without bogging down page loads with extra code.

Create GTM Timer Trigger

To create a new custom trigger, click on Triggers inside Google Tag Manager and click New.

Create a new trigger in GTM

We want to create a trigger that fires five seconds after the page loads. 

There is a built-in trigger inside Google Tag Manager that can help us accomplish this called the Timer trigger.

Select the Timer trigger type for your new trigger

The field Interval determines how long the timer will wait after the trigger to fire a Tag. To achieve a five-second delay on our Meta Pixel Tag, enter 5000 milliseconds in the Interval field.

Set the Interval to 5000 milliseconds for your trigger to make a five-second delay to your Tag firing

If no Limit is placed on this trigger, it will fire a Tag every consecutive interval. In this case, the Tag would fire every five seconds.

We only want to fire our Tag once per page, so set the Limit to 1.

Set the Limit to 1 for your trigger to make your Tag fire only once per page

Finally, we need to set the conditions for this trigger. This will tell the trigger when it should start its timer.

We want this trigger to fire on all pages, so we’ll set the conditions to Page Path matches RegEx .*. The dot-star ( .* ) in regular expression notation means that any value will be considered. The timer will begin on any page on this website.

Set the conditions for your trigger to fire on all pages by choosing Page Path matches RegEx .*

Finally, don’t forget to give your trigger an informative name—Timer – 5 Seconds is self-explanatory—and Save it.

Choose a trigger name such as Timer - 5 Seconds and save it

So, with these settings, we have a timer trigger that fires just once after five seconds on all pages. It is perfect for tracking pageviews from users who don’t bounce.

Build Custom HTML Meta Tags

Now, let’s create a Tag that uses our new trigger and fires a custom Meta event. 

Go to Tags, then click on New

Let’s give this Tag a name to distinguish it from our base Tag. I’ll call mine CHTML – Facebook – 5 Seconds. Click the Tag Configuration field, then choose the Custom HTML tag type.

Name your new Tag and choose the Custom HTML tag type

And here, we need to type exactly like this: 

<script>
  fbq('trackCustom','5 Seconds');
</script>
CHTML - Facebook - 5 Seconds Tag HTML code from above pasted into Tag HTML field

This snippet is a piece of JavaScript. The trackCustom element allows us to create our Meta event. I will use the name 5 Seconds so we can identify it in the Meta Ads interface.

Next, we will attach our five-second timer trigger to the tag we’ve just built.

Select five second timer trigger for new Tag

So this piece of code fires five seconds after each page load. 

Click Save. Now, we’re ready to test our new Tag!

Save the new Tag configuration

Testing Your Delayed Pixel Tag

We’re almost done with this Tag. Our last step is to test it in the Google Tag Manager preview and debug mode.

Enter preview mode on your website. Your base Meta Pixel Tag should still fire when the page loads. Then, after five seconds, you should also see your five-second timer event Tag. This should occur on any page across your website.

Base Meta Pixel Tag and Meta five-second delay Tag firing on the website

If you check the Meta Pixel Helper, you can also see that the PageView and 5 Seconds event has fired.

Meta Pixel Helper showing that PageView and 5 Seconds Tags fired

Finally, we should also ensure that our Meta Ads account is receiving the correct data from these Tags.

In your Meta Events Manager, go to Test Events. Under the Receiving activity list, you should see events for your base Tag (Page view) and timer Tag (5 Seconds) on each page you open while in GTM preview mode.

Receiving activity in the Test events tab showing us that both Page view and 5 Seconds Tags have fired multiple times

If you want to test this more carefully and see results in real-time, you can also click Clear Activity, refresh your webpage, and come back here. You should see the list populated with data from first your base Tag, then your timer Tag.

Click Clear Activity to reset data and see new Tags fire in real time when you refresh your webpage

Setting Tag Firing Priority

We should take one more step to ensure that our implementation is airtight. We want to make sure that our base Tag always fires before the timer Tag, no matter what else happens on the page load.

This is because without the Meta library initiating from the base Tag, the timer Tag will not successfully send information to our Meta Ads account.

In Google Tag Manager, click on your base Meta Pixel Tag.

Selecting CHTML - Facebook - Base Pixel Tag from list of Tags in Google Tag Manager

To make sure that our base Tag finishes loading the JavaScript library for Meta before the timer Tag fires, we’ll be using some advanced settings that instruct Google Tag Manager to fire Tags in a certain order.

Code line 11 in the HTML of Meta Base Pixel Tag begins with fbq(‘init’, which initiates the Facebook Pixel

Under Advanced Settings, find the field labeled Tag firing priority. The higher a Tag’s firing priority compared to other Tags, the earlier it will fire (the default is zero). Any value greater than zero will ensure this Tag fires before our other Tags.

Then, find the dropdown options under Tag firing options. Here, we want to select Once per event. Finally, click Save.

Tag Advanced Settings, setting Tag firing priority to 10, Tag firing options set to Once per event, and saving the Tag

Creating Meta Audiences in the Meta Pixel Interface

Finally, we can create an audience of users tracked by our timer Tag for remarketing purposes. These users are some of the best leads for targeted remarketing since we know they’re interested in our website.

In your Meta Events Manager, click Create Audience.

Create an audience in your Meta Pixel by clicking Create Audience

Choose the Meta Ads account where you’d like to create an audience.

Choose the Meta Ads account where you’d like to create a custom audience

Choose the correct pixel that is tracking your new events. 

Choose the correct pixel that is tracking your new events for your custom audience

Then, we can create an audience of people who have stayed for at least five seconds by selecting users tracked by our 5 Seconds event.

Create an audience of people who have stayed at least five seconds by selecting the 5 Seconds delayed pixel event

We also need to determine how long users stay in this audience after being tracked by this event. Remarketing works well within a short timeframe, so I’ll set this to one week.

Create a custom audience of users who stayed for longer than five seconds in the past week by selecting for 5 Seconds delayed pixel events that fired in the past 7 days

Finally, give the audience a name and click Create Audience.

Set audience name such as 5 Seconds and click Create Audience

With this custom audience, you can target users interested in your website with remarketing campaigns.

🚨 Note: If you’re getting errors in your Meta Pixel, check out our handy guide on how to fix Meta Pixel errors.

FAQ

How do I set a Tag’s firing priority?

To set a Tag’s firing priority in Google Tag Manager, follow these steps:

1. Select the Tag you want to set the firing priority.
2. Under Advanced Settings, locate the “Tag firing priority” field.
3. Assign a value greater than zero to ensure the Tag fires before other Tags.
4. Set the Tag firing options to “Once per event.”
5. Save the Tag configuration.

How do I create a Meta audience?

To create a Meta audience using your delayed Meta Pixel events, you can follow these steps:

1. Access Meta Events Manager.
2. Click “Create Audience” and choose the Meta Ads account you want to create the audience.
3. Select the correct pixel that is tracking your delayed events.
4. Choose the event with users who have stayed at least five seconds on your website.
5. Set the duration for how long users should stay in this audience after being tracked by the event.
6. Give the audience a name and click “Create Audience.”

What are the benefits of delaying the Meta Pixel?

Delaying your Meta Pixel helps optimize your audience for retargeting purposes by excluding users who click on links accidentally or immediately leave the website. It ensures you target a better-quality audience, leading to improved marketing campaign results.

Summary

So there you have it. That is how to delay Meta pixels to build a higher-quality audience.

Check out our guide on Meta Pixel Purchase & Conversion Tracking with GTM, which also improves your ability to track more qualitative data.

Have you tried to delay Meta Pixels from firing with Google Tag Manager? How do you optimize your remarketing audiences? Let us know in the comments below!

Sign up to the FREE GTM for Beginners Course...

[wpforms id="9076262" title="false" description="false"]

Julian Juenemann

Julian is the web analytics instructor and the owner of MeasureSchool. He has 10+ years of experience in teaching analytics tools such as Google Analytics, Google Tag Manager and Looker Studio. He founded MeasureSchool to help marketers with the data-driven way of digital marketing.

Related Posts

Subscribe
Notify of
guest
3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Daniel
Daniel
3 years ago

It would not affect your load time pagespeed?

Sebasthian
Sebasthian
3 years ago

It wouldn’t be more effective start all the pixel code delayed? Making this way your ad rate increase

NOW IT'S TIME TO

Start Measuring Like A Master

Itching to jump into the world of MeasureMasters? This is what you have to look forward to.

Ready to take your digital marketing to the next level?

Subscribe to our newsletter and stay ahead with our latest tips and strategies.