If you find yourself tracking data to multiple Facebook Ads accounts on the same website, you’ll need to customize your scripts to make sure you’re collecting the right information. You might have different Facebook pixels for teams from separate departments or regions. You might also have multiple agencies running campaigns to different sections of your site. Regardless of the reason, it’s important to make sure you have your Facebook scripts set up correctly in Google Tag Manager to avoid sending the wrong data to your accounts.
Improper configuration of multiple Facebook pixel IDs on your site can result in overcounting events and pageviews, send the wrong events to accounts, and can even impact retargeting audiences for your campaigns. Without customization, Facebook conversion pixels send data to any account that loaded on that page prior to that event. If you have more than one team running ads to specific sections of your site, you might have multiple Facebook pixel IDs loading through base pixels on all pages. This could create an inflation of existing events or collection of unwanted events across your accounts.
This post will walk you through how to identify whether you need to set up tracking for multiple Facebook accounts and how to customize your scripts in Google Tag Manager.
Crawl Your Site for Facebook Pixels
Sometimes, you might not even be aware of multiple Facebook accounts on your site or where to find them. This might especially be the case for large sites that have had many agencies or internal teams running Facebook Ads in the past. You can use a few different tools to find Facebook’s IDs across your site. Of course, the first places you should check are your Facebook account and GTM container. Check for unknown conversion names or questionable numbers in your Facebook Ads accounts and multiple Facebook pixel IDs in your GTM container.
Use a Crawler
The most efficient way to find all instances of hard-coded Facebook pixels is to crawl the site. We have a custom crawler at Portent that allows us to schedule and store regular crawls of sites. We can also use our custom crawler to search for or extract specific pieces of script or text. I’ve run these crawls and found multiple Facebook pixels sending unwanted events or overcounting existing events to our primary accounts. These crawls can also be run through tools like Screaming Frog, which has a great extraction feature for licensed users.
First, you might want to run a crawl to find every GTM container so those can be checked for Facebook pixel IDs. To do this, run an extraction to pull the GTM container ID from every page by using this regex: [“‘](GTM-.*?)[“‘]
Once you’ve checked the GTM containers for all Facebook pixel IDs, you can run a crawl to find hard-coded Facebook pixels on every page by using this regex: fbq\([“‘]init[“‘], [“‘](.*?)[“‘]
This will return the Facebook pixel IDs, which can be combined with the Facebook pixel IDs found in GTM containers to create your unique list.
Use Facebook Pixel Helper
You might already know which pages are causing issues. In that case, you can use the Facebook Pixel Helper to see every Facebook hit that’s sent out from a page. The extension will show you every pixel ID that loaded on the page, every event that was sent to each of those accounts, and the details of those events. It will also show you if an event was loaded multiple times on a page:
Implementing Multiple Facebook Pixels in GTM
If there were any hard-coded pixels, you’ll want to remove those and fire them through Google Tag Manager using one of the following methods.
There are two ways to load multiple Facebook pixel IDs in GTM. The easiest way is to use the Facebook tag template. This template does not come by default in your container. Start by adding the ‘Facebook Pixel’ tag template by ‘facebookincubator’ to your container.
Once you have the template, you can easily create or update your tags to point to one Facebook pixel ID or include comma-delimited lists. You should use variables for each Facebook pixel ID so you can avoid manually updating every Facebook tag in the future.
I recommend using the tag template method, but if you need to keep your HTML tags for customization, you can edit your tags to point to the correct ID(s). First, you should consolidate your base pixels into one tag that includes all Facebook pixel IDs:
Then you’ll want to update each standard event script to include ‘trackSingle’ and the pixel ID of the account that should receive that data:
You’ll have to update each script to include ‘trackSingleCustom’ instead for every custom event:
Considerations for Recent Updates
Like many advertising platforms, Facebook Ads is going through a lot of changes in the way data is collected. These changes should be considered in how you customize your pixels to track across multiple Facebook accounts on the same pages.
Facebook pixel updates for iOS 14 limits each domain to only eight conversion events, regardless of the number of Facebook accounts. I recommend organizing all events from every Facebook account that was found on the site and consolidating your list to make sure you meet the limit. Some event names may need to be changed or removed in this process to meet this requirement.
Sites are also increasingly moving toward server-to-server tracking, especially for Facebook over the last year. Facebook recommends sharing the same Facebook events from both your browser and server, in which case Facebook automatically deduplicates the events for you. Facebook does this by looking for duplicates across unique combinations of event names, event IDs, and pixel IDs within 48 hours.
Accurately tracking multiple Facebook pixel IDs across the same domain will ensure clean data regardless of whether you decide to move to server-to-server tracking. Even if you’re positive you only have one primary account, reviewing your GTM containers and crawling your site for instances of Facebook IDs is still a good cleanup practice to conduct once in a while for large sites.