How to Install Facebook Pixel Using Google Tag Manager (GTM)

In this chapter, we will look at how to deploy Facebook pixels using Google Tag Manager.

But first, let’s understand what Facebook pixel is. Facebook pixel is a small JavaScript code that's provided by Facebook for you to place on your Web site. This code allows you to track conversions from any ads that you place on Facebook. This code also tracks users who visit your site too. The code tracks action such as viewing a page so that you can retarget them with relevant messages/advertisements on Facebook. It also allows you to build a list of the target audience for your advertising.

If you are not familiar with Facebook advertising, then the rest of this chapter won’t be applicable to you. If you are familiar, then continue.

Login to your Facebook Ad account and get your Base pixel code. Make sure to select the option to manually install the pixel.

Figure: Facebook base pixel

Configuring the Tag

Copy this code, login to Google Tag Manager and create a new Tag

Since we are not using any built-in Tag, select Custom HTML type tag.

Paste the Facebook pixel code in the Custom HTML tag.

Facebook pixel code also contains <noscript> tag, which basically means that if the webpage can’t fire JavaScript, then it will use a NoScript version of the code. However, when we are putting this code in the head section of our web page and no script does not get fired in the head tag. Additionally, Google Tag Manager is all built-in JavaScript, so if a user has blocked JavaScript, then none of the tracings will work. So, it is safe to remove all the code from <noscript> to </noscript>

Give the tag a name and save it. You will now be prompted to “Save” or “Add Trigger”, click on “Add Trigger”.

Configuring the Trigger

To fully collect the data so that we can use it in Facebook advertising, we need to fire this tag on every page of the sites. We must collect audience information as they interact with our website; no matter which page they are on.

So create a Pageview Tag and set it to all pages.

That’s all you need. Save the tag.

Figure: Facebook Pixel Tag

Preview the tag to make sure it is working fine. If everything looks good, then publish it.

Soon, you'll start to see your audience information in Facebook Ad Manager.

It might take up to 20 minutes before you can see your audience information on Facebook at the manager.


Want to Learn Google Tag Manager. Here are few options:

  1. Get Google Tag Manager Book at Amazon
  2. Signup for Google Tag Manager Course on Udemy
  3. Signup for Optizent Academy and get Google Tag Manager + 20 other courses
  4. Free Introduction to Google Tag Manager course

Related Services

Leave a Reply

Your email address will not be published.