How to Add Facebook Pixel to Google Tag Manager

How To Add Facebook Pixel To Google Tag Manager Blog Header Image - Intigress

Jump To:

Facebook ads and Instagram ads can be key advertising channels for many businesses, but much like Google Ads, they rely heavily on the right data signals to perform effectively. The Facebook pixel is one of the ways to send those data signals into the Facebook system to enhance your advertising performance. If you are using Google Tag Manager to better manage your website tracking, you can add Facebook Pixel to Google Tag Manager (GTM) by following one of the methods in this guide.

Unfortunately though, adding a tag for the Facebook pixel in GTM is not as straightforward as adding Google Analytics to GTM. Chalk it up to the power struggle between Google and Facebook or something else, but you won’t find a premade Facebook pixel tag in GTM. Therefore, to make it really clear, we’ve outlined the best ways to add the Facebook pixel to your website using Google Tag Manager here.

Before we get started, make sure that you have your Facebook pixel code handy, as you’ll need it to use either of these methods. If you aren’t sure where to find your pixel code or you haven’t created a Facebook pixel yet, check out these instructions before continuing.

Add Facebook Pixel To Google Tag Manager Manually

The official Facebook documentation1 recommends that you use a Custom HTML tag to add the Facebook pixel to Google Tag Manager so we will start with that method.

To add the Facebook Pixel manually to GTM:

  1. Log into your Google Tag Manager workspace by going to tagmanager.google.com
  2. Click Tags on the left hand side, then click New
  3. Give your tag a name, like “FB – Pixel”
  4. Under Tag Configuration, choose the “Custom HTML” tag type
  5. Paste your Facebook pixel code² into the “HTML” box.
    1. You can find your pixel code by going to the Facebook Event Manager
    2. Once you’re in the right Ad Account, make sure you’ve selected the correct pixel or create a new one
    3. Choose “Install code manually”
    4. Copy the full pixel code including the script, non-script, and comments and Paste into the Custom HTML tag in GTM
  6. Under Triggering, select the All Pages trigger
  7. Click the blue Save button in the top right corner
Screenshot of Google Tag Manager Facebook Pixel Tag

This is an example of what your full pixel code should look like – just be sure to replace both instances of 9999999999999999 with your real pixel ID.


<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '9999999999999999');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=9999999999999999&ev=PageView&noscript=1"/>
</noscript>
<!-- End Facebook Pixel Code -->				

After you hit Save, your Facebook pixel has now been added to Google Tag Manager.

Add Facebook Pixel To Google Tag Manager Using A Community Template

To make things a little easier, you can use a GTM Community Template to add the Facebook pixel to your website. This is the method we recommend (& use ourselves) because it allows you to leverage the point-and-click user interface which is one of the biggest benefits of Google Tag Manager instead of manually handling the pixel code.

Expert Insight: A distinguished GTM community member created this template to supplement the (non)existence of an official Facebook tag in GTM. A community template is a pre-built configuration that makes it even easier for you to add tags, like your Facebook pixel, to Google Tag Manager.

Since this template asks for your Facebook pixel ID and we can use this same template to add Standard Events3 as well as the Facebook pixel base code4, we recommend creating a Constant variable within GTM before adding your pixel. This will make it easier to reuse your Facebook pixel ID in future tags.

Create A Facebook Pixel Constant Variable

To create a Constant variable, follow these steps:

  1. Log into your GTM workspace by going to tagmanager.google.com
  2. Click Variables on the left
  3. Under “User-Defined Variables,” click New
  4. Give your variable a name, like “FB – Pixel ID”
  5. Add a “Constant” variable type
  6. Enter your Facebook pixel ID (Hint: your pixel ID are the numbers located after “https://www.facebook.com/tr?id=” in your pixel base code. Reference the numbers (9999999999999999) in the pixel code above for more clues on where to find your pixel ID)
  7. Click the blue Save button in the top right corner.
Screenshot of Facebook Pixel Constant Variable Configuration in Google Tag Manager

While you’re not required to create this Facebook pixel ID Constant Variable, we recommend it to save you time moving forward. Once you’ve created it, it’s time to install your Facebook pixel base code into GTM.

Add Facebook Pixel To GTM With A Community Template

To add Facebook pixel to Google Tag Manager using a Community Template: 

  1. Log into your GTM workspace by going to tagmanager.google.com
  2. Click Tags on the left hand side, then click New
  3. Give your tag a name, like “FB – Pixel Template”
  4. Click the pencil under Tag Configuration and choose “Discover more tag types in the Community Template Gallery”
Screenshot of Google Tag Manager Community Template Search
  1. Next, search “Facebook” and select the “Facebook Pixel” by facebookarchive (or visit this link and click “Add to workspace”)
  1. Click the blue  “Add to workspace” button, then click Add to accept the permissions
  2. Add in your Facebook pixel ID (or your “FB – Pixel ID” Constant Variable from the steps above)
  3. This same template allows you to fire other Standard Events, but for now, make sure that Standard radio button is selected and PageView is chosen in the dropdown below.
  4. Go through the rest of the settings to make sure they are set appropriately according to your needs. You may not have to change anything if you just need the basic Facebook pixel implementation.
  5. Under Triggering, select the All Pages trigger
  6. Click the blue Save button in the top right corner
Screenshot of Google Tag Manager Facebook Pixel Implementation with Community Template

After clicking save you’ve added your Facebook pixel to Google Tag Manager. Nice Work! 

Don’t forget, with either of these methods, you’ll want to use the Google Tag Manager preview tool to make sure that your new Facebook pixel tag is working correctly.

Pro Tip: To make sure your Facebook pixel is installed according to Facebook’s best practice5, you can use the Facebook Pixel Helper chrome extension to check to see if your pixel is installed on your site correctly. The extension will also help you understand what data your newly installed pixel is collecting.

In the end, the only difference between these two methods is the amount of code you have to deal with. However, the biggest advantage of using the Facebook GTM Template is that you can also use it to add Standard Events like add-to-cart actions or leads, which can save you time and headaches.

If you run into any trouble installing the Facebook pixel on your website or have questions about setting up Standard or Custom Events, feel free to contact us to let us know how we can help.

Happy Tagging!

Resources

  1. Using Facebook Pixel with Google Tag Manager – Facebook Help Center
  2. Create and Install a Facebook Pixel – Facebook Help Center
  3. Specifications for Facebook Pixel Standard Events – Facebook Help Center
  4. Implementation – Facebook Pixel – Facebook Developers Center
  5. Best Practices for Facebook Pixel Setup – Facebook Help Center

Share This Article

12 Responses

  1. I came here for information on adding a facebook pixel through google tag manager, and tried your template version – it looks like either the author of the template has changed, or the template is no longer available! 🙁

    1. Thank you for letting us know. We have updated the instructions and screenshots to reflect the new author of the template. We also added another link to the template to make it more clear which Community Template to use in case this happens again.

  2. Hi. I appreciate the information you are providing and note that some information appears no longer to be current. As you know, Google has deprecated Google Universal analytics and added a new version GA4 to supersede it. Following your above instructions with adding the UA Constant as a tag, Google now recommends the following when trying to add that that alone: “Use the Google Tag and Google Analytics: GA4 Event tag together to enable measurement for Google Analytics 4”.

    It’s not clear to me how to combine both tags together as I do not see that option in the admin panel nor do I understand what information to add (where do I get it from?) to create the Google Tag. I do have the template added to my workspace, the link you added was quite helpful. Thanks for any assistance that you can provide. I’m hoping when complete this will allow me to manually set up the Facebook pixel and Conversion API to monitor standard ecommerce events on WooCommerce including newsletter signups. Thanks!

    1. Hi Fred! Thanks for your comment. This article is about adding the Facebook (Meta) Pixel to GTM, but your question seems to be about Google Analytics 4 tags. For that, I’d recommend referencing one of our GA4 articles.

      However, because we want to be as helpful as possible, let me try to address your concerns here. First, Universal Analytics is now deprecated so any reference to UA can be ignored until we get a chance to update that. We thank you for your patience and understanding. Second, the GA4 tags are completely independent from your FB tags so nothing needs to be combined there. The quote you referenced is in regards to a recent change where Google updated the GA4 configuration tag to a Google Tag (Read about the change here), but you do still need to use separate GA4 Event tag in GTM to send events to Google Analytics 4. The Google Tag will not do that for you and we do still recommend saving your GA4 Measurement ID as a constant variable in GTM so it can be used in your Google Tag and your GA4 Event tags.

      Lastly, to add the Facebook Pixel via GTM, we do still recommend using the Community Template as described in this article. It will help you add the base pixel code and you can even use to add additional standard or custom events, but you will still need ways to trigger your ecommerce and newsletter events and it will not set up the Conversions API because that is a server to server connection. If you have specific questions, or would like our assistance in setting up GA4 or Facebook tracking, we encourage you to Contact Us.

  3. I completed all of these steps and according to the facebook pixel helper, it looks like it was successful. Thank you!
    But I just realized that I created the pixel under my Business Manager account and not my Ad Account. Did I mess up?

    1. No you did not mess up. The pixel should be under your Business Manager. We’re glad it is working for you!

  4. Hey,
    I already have pixel setup in my woocommerce website through plugin. But it does not showing accurate data. The actual website is lesser than showing in ads manager. Does this article help me to setup pixel through GTM and showing correct data in ads manager

    1. Yes, the method described in this article will help you set up the pixel through GTM correctly. That said, I would expect to see some differences between Ads manager and any other analytics tool as there are a lot of reasons why you could be seeing a discrepancies (i.e. an implementation error in your current setup, different attribution settings, ad blockers, system bugs, etc).

  5. I want to ask since im using GTM code to paste pixel code in my additional code website for tracking.. its successfully track purchase and value but why when i see at ads manager the roas wrong calculated. lets say in dasboard ads manager said have 2purchase..and 2purchase is 158 value.. spent 32.80 so supposed my roas 5+ but in ads manager show 2. 41 so how to fix it

    1. Unfortunately, support for your question is outside the scope of this article. If you’d like help managing, analyzing, and optimizing your Facebook Ads account, please reach out to us via our Contact Form.

  6. Success added Pixel to GTM , but at the Meta pixel helper got

    WARNINGS
    The Facebook pixel activated 2 times on this web page, which can cause errors in your event tracking

    Please guidience

    1. It sounds like you have multiple installations of the pixel. Have you ever installed the Meta pixel on your site before?
      If you would like us to set up your pixel tracking, please consider our Tagging & Tracking service which includes Google Analytics, Google Ads conversions and Meta Pixel events.

Leave a Reply

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

Stay Up-to-date

Find this helpful? Sign up for our newsletter to get this delivered right to your inbox. Plus, get digital marketing news, expert insights, updates, and more.