April 8, 2020
Delay Facebook Pixel with Google Tag Manager (feat. Ahmad Kanani)

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


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 measureschool.com teaching you the data-driven way of digital marketing. My name is Julian.
But today we have Ahmad from Siavak.com 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 expression.star. 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.

9 thoughts on “Delay Facebook Pixel with Google Tag Manager (feat. Ahmad Kanani)

  1. Hi guys. Nice tip. I suggest a better configuration on the advanced tag parameters.
    I don't suggest use tag firing priority but Tag Sequencing. It's more accurate

    So, this is my suggest:

    CHTML – Facebook – Base Pixel
    – Go to Advanced Settings
    – Choose Tag firing options = Once per page

    CHTML – Facebook – 5 Seconds
    – Go to Advanced Settings

    – Choose Tag sequencing
    – Check Fire a tag before
    – Select CHTML – Facebook – Base Pixel

    This is the best way 😉

  2. I usually show this kind of setup as something that GTM users should avoid.

    The Facebook pixel is nowadays more like the Google Analytics tracking code: next to building audiences, you can also use it for reporting functions. And you would definitely not delay the loading of the GA tracking code for 5 seconds. For the same reason you should not delay your FB pixel.
    This kind of technique is the same as firing a GA event after 5 seconds just to lower your bounce rate.

    Also: 5 seconds does not seem to me "the" correct number. But how much should you set? 3 sec? 10 sec? 20 sec? Who knows? How to calculate?
    What if the user has opened your page in the background on a new tab with several other pages to go through and will arrive only after a couple of minutes? Does this mean that after 5 sec this is a valuable user?

    What does it mean: "5 seconds has passed" What do we know about this user just based on this fact? Did this user read the content? Are you sure?

    I am a big supporter of tracking *user interactions* instead. GTM has a scroll tracker trigger and an element visibility trigger: it is so much more informative that the user has actually interacted with the page, scrolled down to some point, has seen specific sections, clicked on CTA buttons, etc. You usually track those interactions in GA. Why not sending those event to your Facebook pixel as well? With that, you can still build your "valuable users" audience but not with the "All users" rule. You may use your custom events in your Facebook pixel like "Scrolled" or "Viewed page section", etc. They will be more valuable and you can also use Facebook Analytics as it is designed to be used.

  3. Nice video! I just have a question. Shouldn't Trigger group be the fastest and easiest solution in this situation? So just to create a Trigger group with 2 triggers (All pages + 5 seconds timer)

  4. Hi! Genuinely would like to know the answer to this but is there a reason that you manually code your Facebook pixel into Tag manager rather than going with the integrated partner option when creating the Facebook Pixel? Also, how can you set up standard events for Facebook via GTM?

  5. Hello! excellent tutorial! I have created the FB 5 sec tag but im not able to see it on FB Manager, does anybody knows why this might be happening? Thanks in advance 🙂

  6. Would be really helpful to put the script in a comment or something for us to copy . I keep getting invalid RegEx
    Unknown Trigger
    Invalid regular expression: “*” This is the script i am using <script>
    fbq('trackCustom','30 seconds');
    </script>

  7. Hi guys great info! Ive added the timer to my own website, when I check it in GTM debug mode it fires perfectly after 5 seconds. I don't see it in Facebook debug mode though or in the Facebook pixel helper. Used this piece of code: "<script>
    fbq('TrackCustom', '5Seconds');
    </script>"

    Thanks!!!

Leave a Reply

Your email address will not be published. Required fields are marked *