Delay Facebook Pixel with Google Tag Manager (feat. Ahmad Kanani)

Delaying the Facebook Pixel from firing when the user enters the website will have the effect of filtering out any user who isn’t really interested in what you have to offer. We can implement such a delay with the help of Google Tag Manager. In this video we’re going to find out how.

🔗 Links:

Timer Trigger for Google Tag Manager:

How to Build a Scroll + Timer Trigger with Google Tag Manager

Siavak –

🎓 Learn more from Measureschool:

🔀 GTM Copy Paste

🚀Looking to kick-start your data journey? Hire us:

📚 Recommended Measure Books:

📷 Gear we used to produce this video:


In this video, Ahmad is going to show you how you can delay your Facebook pixel to build a higher quality audience in your Facebook ads. All and more coming up.

Hello there. Welcome back to another video of teaching you the data-driven way of digital marketing. My name is Julian. But today we have Ahmad from on the channel. He is the web analytics specialist there. And he’s going to show us how we can refine our Facebook audience by delaying our Facebook pixel. So in the end, we have a higher quality audience to do for example retargeting to. Now, we got lots to cover. So Ahmad take it away.

Thanks, Julian. My name is Ahmad and I’m the web analytics especially sets your work. Today I’m going to create a Facebook audience of people who have stayed at least five seconds on my webpage. The reason I’m doing that is because it gives me 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 or see the branding or see the offer on the page. We can use this audience for retargeting purposes. And hopefully we can get better results by advertising to a better quality audience.

Let’s begin by creating our base Facebook tag. For this, let’s go to tag manager and create a new custom HTML tag. I’m clicking on the tag, new, and then see HTML for custom HTML, and then Facebook based pixel. Now,

I use the custom HTML as a tag type and copy paste my code, my pixel code from Facebook to the tag itself. Now, I want the Facebook base tag to fire immediately on all pages. So I set the trigger to all pages and safety Facebook base pixel. That was easy was it. Let’s preview the tag and see how it actually performs on our website.

Now, Google Tag Manager is in preview mode. And we can go back to our website and refresh the page. As you can see, our custom HTML Facebook based pixel has fired one time. And here in my Facebook pixel helper, I can also see that the page view of its my pixel has been fired.

Now, let’s create a custom some events for this Facebook pixel that fires five seconds after the page load. For this, let’s go to Google Tag Manager. And first of all create a trigger. We want to create a trigger that fires five seconds after the page load. Luckily for us, there is a built in trigger inside Google Tag Manager which is a timer trigger. We can choose the trigger type as timer, put the interval, which is 5000 milliseconds which is equals five seconds, and then limit it to fire only once. If we put 10 here, this trigger fires every five seconds for 10 times, but we only needed to fire once. Now, we need to set the conditions for this trigger. We want this trigger to fire on all pages. That’s why I’m going to set whenever the page path matches regular And .star in regular expression means basically everything. Okay, so this time a trigger fires just once after five seconds on all pages.

Let’s give it a name, timer five seconds and save it. Now, we have our timer. Let’s go to tag and create a tag that fires the Facebook event. Tags a new tag. Again, this is a custom HTML tag for Facebook and it fires after five seconds.

For the tag configuration, we choose the custom HTML tag type. And here we need to type exactly like this. First of all, because it’s a piece of JavaScript, and then fbq track custom because it’s a custom event that we’ve created. It’s not one of the standard Facebook events. And we can name it whatever we want. In this case, let’s use five seconds, so we can identify in Facebook ads interface. Now, we’re going to link this tag to the trigger that we’ve just built. So this piece of code fires five seconds after each page load. Let’s save it.

And let’s preview our container. We can either hit preview button here, or hit refresh while we’re on the preview mode. Now, let’s go back to the website and refresh the page.

As you can see, we only have the Facebook base pixel. And then just after five seconds, this new tag fires. If we look at the page view, we can see that the base pixel and these other tag they fired on the page view but five seconds after that GTM timer has fired and with that our five seconds tag has fired. If you check the Facebook pixel however, we can also see that page view has fired and also our five seconds new event.

Now that we have created our events and pixel base pixel, and we are seeing that they are firing and Facebook pixel helper is showing that they’re firing. We also need to go to Facebook to ensure that Facebook is receiving these events. Now here in Facebook events manager, I’m in the test Events tab. Okay. And as you can see, it’s receiving activity, it’s receiving page views. And it’s also receiving five seconds events. If I clear the activity and refresh this page again, and come back here. We can see in real time that first it received the page view. And after five seconds, it receives our five seconds event. Ok.

Now, the final piece that we need to ensure is to come to Google Tag Manager. And for our Facebook base pixel said something names tag firing proceed because we always want our base pixel which contains the initiation part of the Facebook pixel to happen before any other events that we send afterwards. We need to click on Advanced setting and give a higher number like 10 to detect firing priority and then saved the tag.

Any tag with higher priority fires before any other tag with lower priority. So in this case, our base pixel always fires before our event because this is just a piece of code that needs the initiation pixel to be there in order to perform.

Now that we have our tag and triggers set up properly, we can go back to our Facebook Ads Manager within the Facebook pixel interface and create create audiences.

We choose the accounts, we choose the pixel. And then we can choose to create an audience of people who have stayed for more than five seconds for at least five seconds. And then we can set for how many days do we want this audience go. So the people who have stayed for five years seconds in the last seven days. You can give the audience a name and save it.

That’s it. Now it’s time for you to go and try it out yourself. Thank you for watching. Bye.

All right, so there you have it. This is how you can delay your Facebook pixel to in the end build a higher quality audience. Now if you liked this video, then definitely give us a thumbs up and also subscribe to our channel right over there because we bring you new videos just like this one every week. Now, my name is Julian til next time.


Leave a Comment