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

The Facebook Pixel is a standard Tracking Tag that people use mostly to fire once for every pageview of your website.

It sends data to Facebook Ads and Analytics system and enables you to implement Retargeting, Conversion Tracking, and segmentation your audience.

Recently though, we were working with a client who asked if we could include multiple Facebook Pixels onto their page.

I set this up for them and I thought I’d share how I did it.

Why Two Facebook Pixels on the Same Website?

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

Reasons include if 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.

Another case would be if you had different country accounts for Facebook Ads and the main account would track data, but you also want to gather data in the separate country accounts for later retargeting or conversion tracking. This would be along the lines of what’s called a Rollup-Tracking setup for Google Analytics.

Tl;dr – 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

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

In this first step, you need to navigate to your Facebook Pixel settings and retrieve the tracking code. Once in your Facebook Ads account, you can usually find in the Mega Menu under the Reports section > Event Manager > Pixels. There you navigate to your installed Pixel and in the Setup Menu, you click on Install Pixel.

You should see your base pixel (it’s a pretty big code) – Warning: As Facebook changes their interface all the time, this might be outdated once I write this. I hope you are flexible enough to find your FB Pixel.

find-facebook-pixel-code

Copy your code

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

In Google Tag Manager we’ll utilize a CustomHTML tag (although Simo also released a Tag Template you could use) to implement our code.

So let’s head over to our Tag section in GTM, click on New and type as a Name ‘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 want to recommend 3 modifications I usually do to this code:

  1. Get rid of the <noscript> part, as GTM will not deploy this, even if no JavaScript is enabled
  2. Delete the track call fbq(‘track’, ‘Pageview’) as we will separate our track calls from the actual Library code
  3. Set Tag Firing Priority to 100 (this is located under Advanced Settings) – we set this to ensure the Base Code fires before any track calls we implement later on.
set-tag-firing-priority

Lastly, attach an All Pages trigger to your tag to fire on every page view (which 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 1 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 track data should be sent to (according to the Facebook Pixel documentation).

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

modify-facebook-pixel-init-call

This should initiate our Facebook Pixel two times 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. We send these off separately from our Fb Base Pixel code, so we 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 the Custom HTML tag.

Remember that line we deleted earlier? Well, here we can use it.

Let’s implement this into our custom HTML window

fbq('track', 'PageView');

This will send over a Pageview. 

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

What about Tag Priority? We don’t really need to add this, this time, since our Base Pixel now has a higher Tag Priority (of 100) than our track call (by default it’s 0). Therefore we should be all set.

Let’s save this tag and pat ourselves on the back for our tag setup.

Your work with setting up track calls is most likely not done. You might have other interactions you want to track and Facebook has a whole line of standard events that you can send into the tool. Check out this video for another example of a track call.

5. Test and Preview our Implementation

To complete our implementation we have to test if everything works.

Let’s put our GTM container into the Preview Mode (by clicking the large preview button in the top navigation) and head back to our site and reload it.

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

trigger-two-facebook-pixel-pageviews

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

facebook-pixel-helper-trigger-two-pixels

But sometimes it’s 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 inside of your Ad account.  There should be a menu, Test Event you can click.

If you now reload your page, you should see your event being recorded. Everything works as expected.

facebook-testing-mode-trigger-two-pixels

Repeat this step in your second Facebook Ads pixel account and 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, so 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');

Let me know if you have any questions and if you’ve set something like this up yourself in the comments.

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
3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Dóri
Dóri
19 days 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
5 days ago

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