How to Fire Multiple Facebook Pixels on the Same Page with Google Tag Manager

Recently, we worked with a client who asked us, “Can I install multiple Facebook Pixels on my website?”

The short answer is yes, you can!

The Facebook Pixel is a popular tool that you may already be using to send data to Facebook Ads. This data helps you implement retargeting, conversion tracking, and audience segmentation.

However, depending on your tracking and marketing goals, you may want two (or more!) pixels running on one site.

Why would you use more than one Facebook Pixel? And how do you correctly install them?

Here are the basic steps covered in this guide:

  1. Find your Facebook pixel code
  2. Add this to GTM
  3. Modify your base pixel to initiate 2 pixels
  4. Configure track calls in separate tags

We’ll discuss all that and more in this quick tutorial. Let’s dive in!

Why Install Two Facebook Pixels on the Same Website?

There may be special cases where you need to place two tracking pixel codes on a single website and send data to two (or more) Facebook Ad accounts.

Reasons include:

  • A partner you are working with would also like to receive data to build custom audiences or do their own conversion tracking separate from yours
  • Your website serves two or more audience types (or you have multiple product niches) and you want your pixels to track them separately without influencing each other
  • You have multiple Facebook Ads accounts based in different countries that you would like to keep separate for retargeting or conversion tracking (this is similar to Rollup-Tracking setup in Google Analytics)

In any of these scenarios, it’s a good idea to have multiple Facebook Pixels to keep your tracking separate. There are other possibilities, too—just about any setup with more than one Facebook Ads account is a good reason to use multiple Facebook Pixels.

The Solution: Add Two Init Calls

To make this happen, you simply need to add another line of code to your existing Facebook Pixel code (the one that loads the library) to initiate another Pixel.

Facebook Pixel code in HTML field with two fbq init lines

Step by Step – Facebook Pageview Tracking for Two Facebook Pixels

For this tracking deployment, we need to set up one Base Pixel code as well as our Event tracking calls. We won’t need to duplicate any codes, just modify our Base Pixel.

Let’s get started!

1. Find your Facebook Pixel Code

First, you need to navigate to your Facebook Pixel settings and retrieve the tracking code.

Once in your Facebook Ads account, click on the Business Tools menu and select Events Manager. On this page, you’ll find your pixels under your Data Sources.

Select one of the pixels you want to implement on your site and click Setup. You should see your Base Pixel code (it’s pretty big). Copy the code.

Install Pixel popup on Facebook Ads website with step 1: Install base code on website and pixel code

2. Create your Base Pixel Library code inside of Google Tag Manager

In Google Tag Manager, we’ll use the Custom HTML Tag type (although Simo Ahava also has a great Tag template that you can use) to implement our code.

So let’s head over to our Tag section in GTM, click on New and name our tag Fb – Base Pixel – All Pages. Then click on the configuration and in the side menu choose the Custom HTML Tag type.

Now you can go ahead and paste your Base Pixel into the Custom HTML field.

I recommend making 3 modifications to this code:

  1. Get rid of the <noscript> part. GTM will not deploy this, even if no JavaScript is enabled, so it’s just clutter.
  2. Delete the track call fbq(‘track’, ‘Pageview’). We will separate our track calls from the actual Library code ourselves.
  3. Set Tag Firing Priority to 100 (located under Advanced Settings). We set this to ensure the Base Code fires before any track calls we implement later on.
Google Tag Manager Tag configuration advanced settings with Tag firing priority set to 100

Lastly, attach an All Pages trigger to your Tag to fire on every pageview. This will load the library on every page.

3. Modifying the Facebook Base Pixel to Initiate Two Facebook Pixels

With these settings, we followed the standard path of installing the Facebook Base Pixel code and preparing our data to be sent to just one Pixel. So how do we modify it to initiate another Facebook Pixel?

Easy. Do you see this line in the code?

 fbq('init', 'XXXXXXXXXXXXXXXX');

This initiates our Facebook Pixel and configures where our tracking data should be sent (according to the Facebook for Developers page).

In order to send our data to two destinations, we can simply duplicate that line of code and insert the pixel ID from our second account. The result should look like this:

Facebook Pixel code in HTML field with two fbq init lines

This should initiate our Facebook Pixel twice and make sure our track calls are sent to both destinations.

Save this tag and let’s move on.

4. Configure Your Track Calls in Separate Tags 

So far, our implementation doesn’t do much. It initiates the pixel but doesn’t send any data.

So in this last step, we’ll configure our track calls. This is the actual tracking data you want to send to Facebook.

Since we want to send these off separately from our Base Pixel code, we actually don’t have to repeat the large Base Pixel code over and over again for our different track calls.

To create the easiest form of track call, let’s send a generic pageview call to Facebook. For that, we’ll create a new Tag and name it Facebook – Pageview – All Pages. As the Tag type, we once again choose Custom HTML.

Remember that line we deleted earlier? Well, we actually want to use it here. Don’t worry, I’ve saved it for you:

fbq('track', 'PageView');

Let’s paste this into our custom HTML window. This will send a pageview over to our Facebook Ads accounts. 

All we need to do now is add our All Pages trigger and we are done.

What about Tag firing priority? We don’t really need to worry about this for our event Tags. Our Base Pixel has a higher Tag firing priority than our track call, which is 0 by default. Therefore, our Base Pixel Tag will always fire first and initiate the Pixel code, so we should be all set.

Let’s save this Tag and pat ourselves on the back for a successful Tag setup.

You can repeat this process for any other interactions you want to track. Facebook has a whole line of standard events that you can send into the tool. For more on tracking events with the Facebook Pixel in Google Tag Manager, check out our complete training guide.

5. Test and Preview Your Implementation

To complete your implementation, we have to test if everything works.

Let’s put our GTM container into Preview Mode (by clicking the large Preview button in the top navigation) and head back to our site. Be sure to refresh the page.

Once the Preview Panel (at the bottom of our page) appears, make sure you see that two tags have fired. 

Google Tag Manager Preview and Debug console with Facebook Pixel Tags firing

If these fired correctly, we should also be able to see the results in the Pixel Helper Chrome Extension. A closer view reveals that our data was sent to two Pixels. Success!

Google Chrome extension Facebook Pixel Helper showing two Facebook Pixel codes detected

It’s even better to triple check, so let’s enter Facebook’s testing mode. For this, you need to go back to your first Facebook Pixel settings page in of your Facebook Ads account.  Click on Test Events.

If you refresh the page for the website you are tracking, you should see your event being recorded. Everything works as expected.

Facebook Ads account settings Test Events

If you repeat this step in your second Facebook Ads pixel account, you should see similar results.

If you want to see this post in video form with a bit more explanation, then check out our Premium Video content inside of MeasureMasters.

Summary

In this post, I’ve shown you how you can fire multiple Facebook Pixels on the same pageview. By using multiple pixels, you’re able to send data to multiple accounts at once without having to re-implement any code.

By adding another init call, you can initialize another tracker right in the Facebook Pixel and it will automatically deploy your track calls to the destinations you have configured. 

Just add this magic line as often as you need:

fbq('init', 'XXXXXXXXXXXXXXXX');

Have you set up something similar in your tracking configuration? What are some of your favorite applications for multiple pixels? Leave us a comment below!

If you enjoyed this post, you may also find our post How to block internal traffic for Facebook ads useful.

Julian Juenemann
About the author: Julian Juenemann

Julian started and grew venture-backed startups with his unique 'data first' approach to Online Marketing. He then founded MeasureSchool.com to help marketers, like him, the data-driven way of digital marketing.

guest
14 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Dóri
Dóri
4 months ago

Hey! Thanks for the article! 🙂
In case of event tracking, when I want to push the same events separately into 2 pixels, how do you direct the data into the right pixel? We have a client with existing facebook pixel and events and we would like to implement event tracking from GTM to make sure it works as per our standards. So, until everything is tested out and agreed to make the shift between the 2 pixels, we would like to avoid double tracking.

luna m
luna m
4 months ago

The Facebook Pixel Helper seems fine. But only 1 pixel received data in Facebook Events Manager.

Pattara
Pattara
3 months ago

Thanks for the great content. Your information saves me hours!

Francesco
Francesco
1 month ago

Thanks Julian!
Very useful!!
Once I have both pixels settled but I want to create Track Calls that goes to only one of the two pixels, how can I do it?
Right now each data is sent to both pixel. Can I differentiate and direct some data to the first pixel and other data to the second pixel?
Thanks!!

Pete
Pete
1 month ago

Hi Julian,

So if i have two pixels for each page,
PageView
AddToCart
InitiateCheckout
Purchase

what should the code look like, i have two ad managers and a pixel on each manager but want to track each pixel behaviour separately on the same page.

Is this possible

thanks

Pete

Arun Anthony
Arun Anthony
1 month ago

I have 2 pixels initialized but for the second pixel i am getting a warning pixel is not activated

Arul
Arul
1 month ago

Great Article! Thank you!

Iain
Iain
13 days ago

Just what I was looking for thanks

Andre Pascoa
Andre Pascoa
5 days ago

Hello buddy, how are you? I inserted two pixels on the page following your tutorial.

However, two calls were added to the PageSpeed and one call will be added for each installed pixel.

Any solution for that? Because the site will be slower.

See here in the screenshot ==> https://prnt.sc/v7g4vn