[Complete Training] Facebook Pixel Tracking with Google Tag Manager (2020 Version)

Ahmad Kanani from Siavak Analytics is back in our channel to give us a complete Training on how to install the Facebook Pixel with the help of Google Tag Manager.

In this video, he will go walk us through the 3 different methods you can do which are

  1. Automatic Installation
  2. Advanced manual Installation
  3. Facebook Pixel Custom Tag template

Skip to the section
2:37 Automated Facebook Pixel Installation
5:45 Manual Pixel Installation with GTM for Pageview Tracking
13:00 Custom Event Pixel installation
15:45 Setup Tag Sequencing for Facebook Pixel
22:25 Facebook Custom Event Pixel 5 Seconds
26:01 Facebook Standard Event Add to Cart button click
31:34 How to setup Events for 2 Facebook Pixels
32:55 TrackSingle Event option
39:15 Custom Tag Template

🔗 Links:

Ahmad Kanani: http://www.siavak.com
Facebook Tag Template: https://www.simoahava.com/analytics/create-facebook-pixel-custom-tag-template/
Facebook Pixel Documentation: https://developers.facebook.com/docs/facebook-pixel/

Transcript

In this complete training, Ahmad is going to show you how you can utilize the Facebook pixel with the help of Google tag manager.All and more coming up.

Hey there Measure Geeks. Julian here back with another video for you. And today we have Ahmad back on our channel and he’s going to tell us about the Facebook pixel. Now he has really taken an in depth look at how you can install the Facebook pixel with the help of Google tag manager and goes through every different angle of what you can do, like a automatic installation versus manual installation or you can set up events or even how you can utilize the new custom templates that are available in Google tag manager to deploy the Facebook pixel. So there is a lot to cover. This video is pretty long, so we have some timestamps down below. If you are interested and not quite a beginner and you want to jumpin to one or the other aspects of our tutorial today, then check out the links and you can just go to that different timestamp. With that said, Ahmad has lots of cover, so let’s dive in.

Thanks, Julian. This is Ahmad for measureschool. And in this video, I’m going to show you how to install Facebook Pixel with Google Tag Manager in 2020. Here I have a demo store running on WordPress and WooCommerce. And I’m going to use Google Tag Manager to install Facebook Pixel on this shop. We also have an almost empty Google Tag Manager container which is already implemented on this store using free Google Tag Manager for WordPress plugin by Thomas JJ. In this video, I’m going to cover three different methods to install Facebook Pixel with Google Tag Manager. The first method is automatic installation. It is simple, it is quick but it is limited and I actually do not recommend it. I’m going to spend just a few minutes on it.

The second method, which is the bulk of this video tutorial is going to cover the advanced manual installation of a Facebook Pixel using Google Tag Manager. This is flexible, this is powerful and I actually recommend doing so. In the final method, I’m going to show you how to use custom templates, custom tag templates to do what we’ve done manually in step two, but quickly with the same level of flexibility and power. And it is also a method that I actually recommend. We only have a little bit of time, and we have a lot to cover. So let’s begin.

First, let’s navigate to Facebook Ads Manager and find our pixel. For this. I’m going to go to menu, events manager, select my pixel. And here at top right, I’m going to click setup and install pixel. As I said, the first method is automatic installation using a partner integration. If you click on partner integration, we will see a list of icons for the different platforms and tools that Facebook already integrates with. Among these is Google Tag Manager. You can click on Google Tag Manager, connect and verify on Google Tag Manager account and let Facebook do it for us. Before moving forward. Let me tell you why I actually do not recommend this method. It is because when you authorize your Google Tag Manager, and verified for Facebook, Facebook actually goes inside the Google Tag Manager creates a tag or a trigger, assign trigger to the tag and publishes your container immediately. Okay, so if you have any changes or work in progress inside your container if someone else is already working in your container and creating tags, etc, and you do not want to publish it immediately to a website, it can make things complicated, and possibly bracings. So this is one of the reasons that I do not actually recommend doing that. But I’m going to cover it anyway, quickly. So let me click Continue. Authorize my Google account. Actually, let’s bring this to you. Give permission to Facebook is logging into my Google Tag Manager account, it can see the container and the account. And all I need to do is click Finish setup.

At this step,Facebook is trying to help me set up extra events as well, which I’m not going to do. I just want to go back to Google Tag Manager, refresh so we can review the tags to see what Facebook has done. And here it is, the Facebook Pixel tag already created. The workspaces changes are zero which means the workspace has already been published. So Facebook has come in, created the tag, assigned a trigger, published a container, created a new version, which is now we can see version two has just been created with no name. So Facebook didn’t even assign a name to the version that it has created. That is why I don’t like this automatic installation method because it doesn’t give you control, it doesn’t give you flexibility and auto publish this a work in progress container which might cause confusions or create complexities. So this was it. The first method automated tracking. By all means, if you don’t have time, or if you know what you’re doing, if you just want pageviews to be tracked, you basically go to Facebook ads interface, click setup and authorize your GTM container, authorize Facebook to access your GTM container, click continue a few times and bam, it is done for you. It is finished, you can go with the rest of your day. But if like me you like control, more flexibility, more power. Let’s do things our way and continue with the second method which is manual tracking. Let’s go back to Facebook Ad manager and click setup again into the pixel. And this time instead of add code using upon integration. I’m going to choose manually add pixel code to your website. Here Facebook instruct us to add this base code on every page of our website. I’m going to click here to copy the code on clipboard. Let’s go back to Google Tag Manager. I’m going to remove this tag.

Let’s delete the tag and create a new one. Let’s call it Facebook base pixel. I’m going to click here. And because we don’t have any built in tags for Facebook that search there is nothing yet. We need to create a custom HTML tag and paste the JavaScript code that Facebook has given us inside this area. Let’s assign a trigger to our tag. We want it to fire on all pages. And let’s save it.

But before we preview the container and verify the setup, let’s take a closer look at the Facebook Pixel code. So Facebook Pixel has two main points. The first part is the script part of it from line two to line 13. And the second part is no script part of the code. The no script part of the code is for the browsers that have JavaScript disabled. So if a page loads in a browser, and browser does not support JavaScript, this is the portion of the code that is going to be executed. But because Google Tag Manager container has actually been made of JavaScript, and Google Tag Manager executes custom HTML when JavaScript is actually supported, we need to take this piece of code out and put it in an image tag.

This is not so critical. And to be honest, most browsers actually support JavaScript. And if they do not, your website is not going to function correctly anyway, in most cases, at least. Now let’s go back and take a closer look to the first part of the script from line three to 10. We have a function, FB events, which is loading a JavaScript library from Facebook service. Once the library is loaded, on line 11, we have the pixel initiation code, so FAQ in it, which means initiate and send your facebook pixel ID, this line of code actually uses this library to initiate that facebook pixelon your page. Or let’s say activated. When the Facebook Pixel is initiated or activated, it will listen to events to collect them and report them to Facebook ad manager.

This line line 12 is actually an event. It tells Facebook to track a page view and send it to this pixel that has already been initiated. So that’s quite simple. It loads a library, initiate your pixel, and it will track the first event to that pixel, which is a page view event. Now that we know this tracking script works. Let me just take out another script pause, and we can save this tag in preview the container to verify our setup. click on preview, wait for Tag Manager to refresh and enter the preview mode. And now let’s go to our website and refresh the page to preview the container. Okay, great. As we can see, the Facebook base pixel has already been fired. And if we check the facebook pixel helper, we can see that a page view event has been fired. And also some micro data has been automatically detected. This is the page view. There are some information about a page view like the URL being recorded. The pixel code was FAQ track page view, and the location was the URL of this website.

Now let me tell you a bit more about this automatically detected micro data. So when we install Facebook Pixel on the page, it tries to automatically detect some context about the page and some other user interactions like button clicks, etc. Okay? These are events that are detected automatically there are identified with a blue lightning icon, whereas the events that we actually set up and fire ourselves within our implementation, Google Tag Manager, etc. They are being identified with a green checkmark. So the tag is being fired and facebook pixel helper is actually detecting the page view event. Now let’s go to Facebook ad manager and actually verify that Facebook is actually receiving the events. In Facebook ad manager, if we click on test events, it will show us all the recent activity for that pixel in real time. Let me clear the activity list. And let’s go back to the website and refresh it one more time. And then go back to Facebook ad manager. And now as we can see, there’s a page view right now coming from this website to Facebook Ads Manager. Now if I navigate back to the website, and we use some products, or for example, click on quickly button, we can see here that the button click has automatically been detected. But here on Facebook pixel, even if we refresh, we cannot see that automatically detected button click in the list. To be able to see those activities, we actually need to go to menu, expand menu, go to Facebook analytics, select the pixel that we’re using, click activity and check event debugging. Let me refresh the list. Here we can see all the events, even those that are automatically detected like micro data and button clicks. Now I would like to mention that although Facebook can detect micro data and some events like button clicks, these are not completely accurate, it can be unexpected in accurate, and Facebook will try to pick up the user interactions, it will try its best to pick up the user interactions and the context around it. But it’s always better that we deliberately track events for the button clicks that are important for us. And the context around those activities. Because if somebody can click or some data about the page is important for me to track to Facebook, and I want to use it reliably for conversion tracking, I mean, if I need custom conversion, or if I want to use it to create custom audiences, I want my data to be reliable and I want to be sure that the information is being recorded the way that I intended to be.

Let’s quickly recap what we learned up to this point. So we learned how to track pageviews to a facebook pixel with two different methods, the automatic tracking done by Facebook Not recommended. And to manual tracking, that we actually set up a tag and trigger inside Google Tag Manager, and we could verify that we are tracking the page view. Now, if you only want pageviews to be tracked to your facebook pixel, that is all unique. We can use these page views and their URLs in Facebook Ads Manager to create custom conversions, and you can also create custom audiences and run remarketing ads.

In the second part of this tutorial, I’m going to show you how you can get the most out of your facebook pixel tracking by setting up event tracking. Because pageview is just one simple user interaction. It doesn’t mean that people have actually interacted with the page clicked somewhere, watched a video, added something to cart or actually purchase a product. When we start tracking events. Not only we can see how many times that event has been fired,but also we can create custom audiences based on that event. And we can define that event as a click conversion. So we can use that custom conversion to optimize our Facebook campaigns for. Some examples of events that we can track to a facebook pixel can be spending time on a page. So if user spends 10 seconds on a page, if users clicks on a button, so pixel leads form, interacts with a video as a product to cart or makes a purchase. There are two types of events that we can track to a facebook pixelstandard events and custom events. Standard events are several popular user interactions that are recognized by Facebook, such as lead viewing contents, a viewing a page that is interesting for you, you want people to view that page, adding a product to cart, initiating the checkout process by clicking on the Checkout button, purchasing the product and many more. But even if Facebook doesn’t recognize an event as a standard event, for example, let’s say we want to track people that is spend five seconds on our landing page. This is a user interactions, we want to track that they spent five seconds. It’s important for us to know that and we can create audiences based on that. But it is not within the list of a standard events in Facebook. And that’s fine. We can create custom events and we can name them whatever we want. And we can track them to Facebook Pixel. I will show you how to do that. Let’s start and track some events. I’m going to navigate to Google Tag Manager. First thing we need to do is that we need to separate this Facebook base pixel into two parts. We actually need to take out the fake Facebook page for your tracking code, FB cue track page view and add it to its own tag. We want to separate the initiation part of this pixel from the first event. This is because we want to find more events are the events different than this page view. And those events will also require the pixel to be initiated for them. Otherwise, they would not function correctly. So the sequences like this, the facebook pixel must be initiated before an event can fire and be picked up by the pixel and reported to Facebook. That’s why we would like to execute the base initiation part of the pixel just once, and then use it for every other event that we want to fire on this page. Let’s take out this event, this pageview event first, save this tag and create another tag. I’m going to call it Facebook page view. page view, my bad. Okay, now I’m going to choose custom HTML, we actually need to add the opening and closing script tag here and paste FAQ page view here. We want this page view event to fire on all pages. That’s why we need to assign it to all pages trigger and save it.

Now we have the Facebook’s base pixel and the page view event, both firing on all pages and page view event. And the question is, can we be sure that Facebook’s base pixel always fires before the page view event. As a matter of fact, we don’t know that because Google Tag Manager fires tags asynchronously, it is not possible to tell which one fires first and which one fires second. So we need to figure out a way of assigning an order of firing to these two tags. We want to base pixel to fire first, finish its execution. And then the page view events to be fine, because at the time this event fires, we want the base pixel to be initiated. Otherwise, this would not function. In Google Tag Manager, yhere are two ways of assigning the firing orders to tags. The first way is called tag firing piratey. So the Firing priority of each tag by default is zero. If we assign a firing priority of 10 or 100 to Facebook base pixel, it will ensure that Facebook base pixel with fire first because it has a priority of 100. And before Facebook page view, which has a default firing privacy of zero, the higher the priority, the sooner the the tag fire, but I’m not going to use this method. Because tag fire priority only ensures that this tag fires before this tag. It does not guarantee that the Facebook base pixel will finish the execution before the next tag is going to. So technically it is possible that this tag for his first two milliseconds later, this tag fires even before the base pixel finishes loading the library from Facebook and initiating the tag.

So we need to use the second way which is tag sequencing. In tag sequencing, we can assign an order to tags to fire and Google Tag Manager will actually ensure that the first tag has been fired and executed completely before it goes on and fires the next. So this is what I’m going to set up right now. Let’s click on Facebook page view. Click on the tag, open advanced setting and open tag sequencing. As you can see, it says tag sequences allows you to specify tags that will fire immediately before or after this tag. In this case, we want to fire a tag immediately before Facebook page view. Just to recap, this is just an event, it needs the base pixel to be initiated before that Okay. So did tag that fires before Facebook page view tag will be called this setup tag for this Facebook pageview tag for the current tag. You can select the tag and set up Facebook base pixel to be the setup tag for Facebook’s page view pixel. We can also ask Google Tag Manager not to fire Facebook page view this tag if Facebook base pixel fails to execute. And I’m going to check this because yes, if Facebook base pixel fails to fire or fails to execute, there is no way the single line of code will work. It doesn’t know where to send data to which facebook pixel to send data. And there is no listener to listen for this event. Okay, that’s it. So we’ve set up the tag sequencing to ensure that Facebook base pixel always fires before Facebook page views, always fires and finishes execution before Facebook page view. Let me save this. And now I’m going to ask you another question. If you’re going to set up two or three different events like Facebook page view, Facebook add to cart Facebook, initiate Checkout, Facebook lead, different events.

All of those events will also need to have tag sequencing. For all of those events, we also need to set the Facebook base pixel as the setup tag. Okay, now does it mean that facebook pixel tag will fire multiple times. So every time an event is going to be fired, Google Tag Manager is going to fire Facebook base pixel anyway, before that event. This is not efficient. We don’t want facebook pixel to fire more than one time. If it is there, if the pixel is initiated already, we don’t want it to fire anymore. That’s why we need to set another configuration. This Time In Facebook base pixel, we need to click on tag configuration, click on Advanced setting and on the tag firing options instead of once per events. We want to set up this tag to fire only once per page. So in case that this Facebook base pixel has already been fired once per each page for every Other event that is going to fly on that page. Even though if defined base pixel as the setup tag for that events, it will not fire again, it will fire just once per page, just to ensure that the pixel has been initiated, and is ready to listen for all the other events that we are going to fire on that page. If for any reason this fails to execute first time, then when page was going to fire it’s going to call this anyway it has not been executed, it will be executed. But not for the rest of the events that are going to fire on that specific page. Now that we have everything ready for event tracking, let’s add another Facebook event.

Let me just copy the code for page view events because I’m going to use it. Let’s create a new tag. This will be Facebook, five seconds. I’m going to fire any went when someone spends at least five seconds on the page, so if someone lands on my page and just hits the Back button immediately, I don’t want to fire this event for them. This can be used later on in Facebook to create custom audiences that are higher quality of people that have actually had the chance to view the page. Okay, so for the tag configuration, I’m again going to use a custom HTML tag. Instead of FB cue track, I’m going to write FB cue track custom because five seconds is not a standard event that Facebook recognizes. And I’m going to call my event five seconds. I can call it anything I can call it five sex. I can call it five dash seconds, anything really, it’s up to us to decide what would we like to name our event. So this is our events. And now I’m going to assign a trigger to it. But before that, let’s make sure we will have our tax sequencing setup. So we want to fire attack before this one fires, that would be our Facebook base tag. And we don’t want to fire this if that base pixel fails, or is paused or fails the execution now before saving it, let’s assign it a trigger. We don’t have any five second timer trigger. So I’m going to create one quickly, it would be a timer for five seconds, and I’m going to use the timer trigger. This is a millisecond. So I’m going to put 5000 here limits just one time. And I wanted to find out all the times and matches regex dot star means all time in all situations. Let’s save it, save the tag, refresh the preview and see if our events actually works. Okay, let’s go back to the website and refresh the page and see what happens. Okay, We have our G pageview, Facebook page view, Facebook base pixel and Facebook five seconds, it actually took five seconds for it to run. So page view microdata and Zen five seconds.

Now to absolutely make sure that Facebook is actually receiving this data. Let’s go to the pixel events manager. Select the pixel and test events, can your activity go back to the website, refresh the page, wait for the tax to fire and then come back here. And we have our five seconds custom events here. Recorded in Facebook knows that page view there is no custom events written here because it is a standard event. Now let’s go back to the website and try and track a new event. A standard event. This time I’d like to track the click of an Add to Cart button. Okay, let’s go to the shop section. And I’d like to do it quickly because I want to have time to cover some advanced tricks later on. So here, if we choose a product, we can see the Add to Cart button here, I want to track the click of Add to Cart button to track and standard events, add to cart or Facebook ads. If I click on this button right now, nothing happens because I haven’t yet defined a click trigger in this Google Tag Manager container. So we first need to go back to Google Tag Manager container, go to triggers and add a new trigger. I’m going to create a new one. Call it all clicks. I’m going to choose all elements and all clicks because at this point in time, I want this trigger to fire for every click on the website so I can check the click text, click classes, etc. and limited to the Add to Cart button only. Let’s refresh the container. Go back to the website. Refresh the page and here we are Okay, so now if I click on the add to cart, we have number six click event. If I click on this click event, click on the click event and take a look at the variables we can see two are no variables. That was a big mistake. To be able to use the click variables, we need to first enable them. This is a brand new container. They almost always have them enabled, but not for this one.

So let’s go back quickly into the variable section, click Configure, and enable all the built in click variables in this container, okay, now it’s on a mistake anymore. Refresh the container back to the website, refresh the page. And here we go. Okay, now if I click on Add To Cart again, we will have the click events. And if I click on the click, and go to the variables tab, now we can see what was the click losses, click elements like ID, etc. So the way we can limit this clicker just on he clicks on the Add to Cart button is either limiting gates by the criteria that the click clauses should contain single Add to Cart button. Okay, this is one way of it. And the second way of doing it is to limit it to when click text equals Add To Cart. I’m going to use this one, to be honest because maybe somewhere else and the same there is an Add to Cart button, and people want to click on it, but it doesn’t have the exact single Add to Cart button class. So for the purpose of this tutorial, I’m going to use click Next. You always test always check all the pages and paste templates before actually pushing anything to life. So let’s go back to tag manager. Go to triggers, edits our trigger. So this is not all clicks anymore. This is at two cards, click and then if we click on trigger configuration, we don’t want it to trigger on all clicks, just some clicks when clicked x equals Add To Cart. Let’s go back and make sure it was capitals your lowercase E, okay exactly cart with lowercase c over save it and refresh the container, we can be sure that this trigger only fires when someone clicks on an Add to Cart button. Okay, now let’s go back to tags. This time, I’m going to find my Facebook five second pixel, I’m actually going to copy it and duplicate it. So if I click on this menu and select Copy, it creates another copy of the same tag, I can change the name so instead of five seconds, I can say Add To Cart. Okay, and here. This is not track custom anymore because Add To Cart a standard event recognized by Facebook. And if I’m not mistaken, it is written like this with capital T and capital C. But I need to check that once again in facebook pixel because we have copied another event tag. We have already To set up our tag sequences tag sequencing, as the only thing we need to do is to remove the timer trigger and switch it with the add to cart collector. Now let’s save the tag. preview the container.

This is the same as clicking on refresh, you can either click Preview or refresh. Now refresh the page. Let’s see what we’ve already got page view micro data automatically detected and five seconds. Now if I click on Add to cart, there’s a click trigger and descriptor got a new tag has been fired to Facebook add to cart and here we have five. So the add to cart event that we have set up and triggered ourselves and the button click automatically detected. So button click form features there are lots of things that Facebook could actually pick up when the button was clicked. So this is automatically detected one. And the add to cart event is our event which we can see the URL card and pixel locations etc Going back to Facebook ad manager, we can see the ads are gone. And it has already figured out this is in standard events, we can see it by looking at this icon. And this is not a custom event. Now before we proceed to the third and final method of facebook pixel tracking, I want to show you an advanced trick. And that is how to achieve accurate event tracking with multiple pixels. Now in this example, we only have one Facebook base pixel initiating on the page. But there can be examples of the situations that’s on more than one base pixel being initiated on a single page. I mean, there could be multiple stakeholders and wives. They could be two or more agencies working with the same brand. Some of them might be doing brand advertising and the other one could be doing performance marketing, and they may wants to track data into their own Facebook pixels different, they might have different strategies of the events and the data that they want to track to their events. But for all of these pixels, the base pixel should be initiated for the events to actually function properly. Now the problem is, let’s say we have more than one pixel on the page, let’s copy this pixel, the base pixel. Okay, and let’s call it facebook pixel number two, and actually change the pixel code as well.

Okay, ending with zero, and let’s save it. Okay. Now, if we preview the container and refresh the page, we can see that we already have two facebook pixel initiated on this page. So let’s see what happened when the page loaded the first facebook pixel that we had number one, it has been initiated. Okay, the page view event has been fired. microdata detected and before For five second passes, the second facebook pixel has already been initialized. And the second page view for that pixel has been recorded. Now, back in Tag Manager, we don’t have to Facebook page views Do we? We don’t have there is only one Facebook page view. So by the time that this Facebook page view event has fired, both of these pixels have been initiated. Let’s take another look. So this pixel initiated page view event fired for the first pixel it was fine, but for the second pixel, it seems to be firing sooner than the second base pistol. So Facebook’s that we detected that event code, but no pixel has been activated for it, but when five second passes from the page load, and both base pixels have already been initiated, this one and this one, and we have our five second event firing both of these pixels here. Catch the event and reported completely normally. So you can already see that lots of things that can go wrong when we have multiple pixels initiated on a page either, and event firing, after those pixel have already been initiated, will fire to all of these pixels, or some of the events will fail to fire to the pixel that they were supposed to fight. So basically, if we had like 10 pixel on this page, and we had a purchase, or add to cart events firing, just like now let me click,let’s see this add to cart it will be recorded for the first pixel and for the second pixel and for any other pixel that has been initiated on this page. Okay, so what’s the solution? There is a solution for this and it is called track single. So if you take another look to our event tracking code, it is FB cue track, but we can change it to FB cue track single that means track this event to a single pixel. And then we need to specifically tell Google Tag Manager to reach a specific pixel. Do we want this event to be tracked to? Let’s say, we just want the events to be tracked to our first facebook pixel here, because right FAQ tracks angle to this facebook pixel page view and save it. Let me actually copy this. So right now we limited the page view event to be fired only for the base pixel. Now I’m going to also limit the add to cart and five seconds to only fireto the first pixel. So track single to this pixel Add To Cart.

Let’s save it and here it is a bit different.I will show you now track single custom because it’s a custom event so track single to a single facebook pixel bots a custom event to display All comma five seconds, save this one as well. So we will have two base pixels initiated. But within this Google Tag Manager container right now, we are only firing events to the first pixel. Let’s refresh the preview, go back to our website, refresh the page and see what happens. Okay, here we go to add three, and add to cart, everything are just being recorded to the first pixel. Now what I can do is that I can easily move add to cart to be recorded to the second pixel. It would be easy, isn’t it, we just need our second pixel ID, which is this and we can have our ad to cause events to only be tracked to this one. And we need to make sure that we have set our second pixel as the setup pixel for the add to cart event. Refresh the website Let’s take a look up to this point, only patriot and five seconds are being tracked to the first facebook pixel. But as soon as I click on Add to cart, we will have the second pixel and zeros and add to cart has only been recorded with district so not with the first pixel.

Now let’s take a quick look on how we can use these events as they are recorded in Facebook ads. So first thing we can do with these events is to create a custom conversion, we can click on custom conversion, create a new one, select which event do we want to count as a custom conversion. In this case, I would like to set add to cart to be a custom conversion. There is no rule needed. And I’m going to name it Add To Cart. There’s no value assigned to it yet. And for some strange reason, it doesn’t allow me to create the custom conversion unless I guess I add a rule. So all of the URLs of this web shop they Have demo that shop exam. And now we can create our Add To Cart conversion.We can then 

come back and take a look at how many times this conversion has actually happened and use it to optimize your campaigns for let’s quickly recap the second methods manual tracking of facebook pixel in Google Tag Manager, we learned how to install facebook pixel manually using a custom HTML tag. We learned why it is better to separate the Patriot event from the Facebook base pixel initiation part. We learned how to use text sequencing to make sure that the pixel is initiated first, and before any event is being fired to be recorded by that pixel. And then we learned how to accurately track events with multiple pixels on the same page. Finally, we saw how we can actually use these events in Facebook Ads Manager to create costs Some conversions, or custom audiences. Now it’s time to learn the final method that says better custom tag templates provided by Seymour hava. If you don’t know Seymour haba, please go look him up. He’s very knowledgeable in Google Tag Manager. And he is kind enough to share many solution on his blog, and also right now with his custom tag templates. Now, let’s go to Google Tag Manager and see how it’s done. Actually, remember how we first started to track facebook pixel manually, and we wanted to create a new tag, we had to use custom HTML tag, because there was no built in tag available for Facebook. Well, in 2019, Google Tag Manager introduced a new feature called custom templates. custom templates are basically like the built in tags, and you can find them in the community template gallery, but the difference between custom templates and built in tags is that built in tags or created by the platform itself, or by Google Tag Manager itself. But anyone can create a tag template and share it with others to use one person who’s creating very high quality tag templates and sharing them with the Google Tag Manager community is Seymour haba. And he actually has created a Facebook tax template as well, which we can use to easily implement facebook pixel through Google Tag Manager without losing any flexibility, power, or control. Let’s add it to our container. Here you have the template details in his facebook pixel provided by GTM templates. The Mahabharat is a tag This is the description what’s new, what kind of permissions does this tag need, it wants to lock console access global variables and check script which is basically the facebook pixel scripts provided by Facebook and you can see the link To documentation homepage and the date that it has last updated. If we click Add to workspace, it asks us again, if we want to actually add it. Because custom templates are made by others, we need to make sure we only add templates that we actually trust the source of. So working with this custom tag template is really easy. Let’s first give it a name quickly, CT for custom template, the only thing we need to do is to provide the facebook pixel ID and then choose what kind of events do we want to fire either a page view, or any type of a standard event, or maybe a custom event that we can name however, we want. Let me just quickly grab the value of the facebook pixel and paste it here.

And we can choose page view and we add a trigger to trigger on all pages. Save and we’re done. Let me quickly Remove all the other Facebook tags that we created manually. Okay, now the only tag we have is Facebook page view custom template. Let’s refresh the container. Go back to a website and refresh the page. Here we go, facebook pixel custom template has been fired and we will have the page view and micro data. Now let’s go back and quickly add the add to cart and five second tags. I can easily copy this, rename it to add to cart custom template. From the list of events I can choose Add To Cart add for the trigger instead of pageviews. I can add it to add to cart clicks and save it and I can copy it again.

And save it. Now let’s refresh the container and refresh the page. So we have our page view microdata, five seconds. And I can also click Add to cart and we will have our Add To Cart event recorded. Now the beauty of this custom tag template is that it automatically makes sure that the Facebook base pixel is initiated before each of these events and it does not fire twice or three times or before any other events. There is no text sequencing required there is no requirements for creating setup tags, etc. Or separating the base pixel from the event. You just create the tag. You just set up the events and it will take care of everything else automatically. The other nice feature of this custom template is that it is by default sets to track single, because when we are defining the custom template tag, if you’re actually putting the facebook pixel ID inside the tag, it only fires the event to the same pixel ID that is specified here and not any other pixel ID. So it is track single by default it will take care of the tax reacquainting by default. It is really flexible and powerful and quick way of doing a manual setup without all the hassle. Now before I wrap this tutorial, I want to show you two other features that this custom tag template has that either are really hard to accomplish with manual tracking. Or maybe for me at least, it is impossible because I I don’t know yet how to do it.

So the first thing is that under more settings, we can actually disable the automatic configuration. This actually does save builds the ability of facebook pixel to collect metadata, you saw that Facebook was trying to detect button clicks and metadata automatically about the page. If you check this, it will disable that functionality. And the other thing is that there is a setting that allows you to hold the event from being fired until tracking consent is given by the user. So by default, as you can see here, we’ve put this on true. But if you put it on false, it means that by default, we do not assume that the user has been consented to be tracked by Facebook and the tag will fire but it will not be executed it will be on hold until another tag with consent granted set to true fires.

So the tag will kind of queue and wait before user gives consent either by clicking I accept or I agree or, yes, I want to tract. And then when user accepts to be tracked, then all the events that have been queued will fire and will be recorded to Facebook. This is really good for compliance purposes, especially with GDPR when you need to definitely get user’s explicit consent before doing any marketing tracking. So to recap, this was a really long tutorial, I hope you’re not tired. We covered three different methods of Facebook Pixel tracking via Google Tag Manager. The first one was automatic installation, which I do not recommend. The second one was manual installation with absolute power and control, which I do recommend, but it was a bit hard and complex to achieve, especially with tag sequencing and accurate event tracking with multiple pixels. And the final method is the custom tag template provided by Simo Ahava which has the same amount of flexibility and power, but it is much more quicker and easier to use. And I actually definitely recommend. I hope you’ve enjoyed this tutorial. And I hope you can actually use what you’ve learned in your work. This is Ahmad, thank you very much. Bye

This was a lot of content in a very short amount of time or long amount of time. If you watch all the way through it then congrats.You’re probably now very familiar on how to utilize the Facebook Pixel in its different areas with Google tag manager. Now there is always more to learn with the Facebook pixel and a few more tricks. So we actually have a playlist that we have linked up down below. Maybe we can also show it at the end card right here in a second, and you will be able to learn so much more about the Facebook pixel and be a bit more efficient with it as well. That said, if you are new to the channel, we’d love for you to subscribe down below we have a button that says subscribe, and there’s also a bell, which you can click and then you will be notified with everything that we do on this channel. Now my name is Julian. Til next time.

Leave a Comment

avatar