Stape
Search
Try for free

How to integrate Facebook Pixel with a web GTM container

Uliana Lesiv

Uliana Lesiv

Author
Updated
Apr 3, 2025
Published
Apr 2, 2025

Stape has developed a tag for web GTM containers that allows you to add Facebook Pixel to GTM and efficiently manage data collection. In this article, we consider the benefits of integrating Facebook Pixel with GTM, and show you how to do it using the Meta Pixel tag by Stape.

What are the benefits of integrating Facebook Pixel with GTM?

Google Tag Manager is a handy hub for data tracking management without directly modifying your website's code. Integrating Facebook Pixel with GTM allows you to track the events you need easily; besides the standard ones, you can set custom event tracking.

GTM integration offers a convenient way to send event data to the Meta platform. With its help, you can keep all the tracking solutions you use besides Facebook Pixel in one place (e.g., Google Analytics 4, Google Ads).

Stape's Facebook Pixel tag

Stape has developed a tag that allows the integration of Facebook Pixel with a web GTM container. The tag provides a hassle-free option to inherit data from the DataLayer, automatically parsing and mapping available event data. Alternatively, you can override the data and manually send information for standard or custom events.

Also, you can configure consent, which is important in the numerous data regulations. If you use server-side tracking, the tag allows deduplication of the same event if it is sent from different sources.

How to integrate Facebook Pixel with GTM

1. Download the Facebook Pixel tag from GitHub and upload it to the web GTM container.

Import FB Pixel template in GTM

Currently, the tag is unavailable in the GTM Template Gallery. But it will be added there in the future, so you can start using the tag by simply searching for it.

Search template gallery in GTM

2. In the "Tags" section of the web GTM container, click "New" and choose "Facebook (Meta) Pixel" as the Tag Configuration.

FB Pixel template in GTM

3. Configure the tag.

3.1 Add Facebook Pixel ID - you can find it in Facebook Business Manager → "All tools" in the left-hand menu options → "Event Manager" → "Data Sources". In the "Settings" tab, you can find Dataset ID. Check our article for more details on how to find Dataset ID in Meta.

Dataset ID in Meta
Tip: Use a constant variable for Pixel ID to avoid retyping the ID whenever it is required.

3.2 Select Event Name Setup Method:

  • Inherit from DataLayer - with this option, the tag will automatically parse event data and map available data.
  • Override - it allows replacing or modifying the default values of variables, parameters, or settings when a tag fires.

3.3 (If selected "Override" as event name setup method) Choose the Event type you want to track: standard from the list of available events or a custom one.

3.4 Check the boxes if it meets your needs:

  • Enable automatic data population from the Data Layer - if you check this, the tag will automatically populate standard Object Properties and User Properties from the DataLayer. Tag parses Google Analytics 4 and Common Event Data formats.
  • Use only data from the last DataLayer push - in this case, the tag will take data only from the current DataLayer event if enabled. So, only data pushed to the DataLayer last will be used.
  • Enable Advanced Matching - with this option, you allow sending users personal information such as email addresses, names, etc. to Meta. Find more details in Meta's documentation.

3.5 Configure Compliance section:

  • Consent Granted - if you set Consent Granted to false, it will prevent the Pixel from sending hits until the tag is fired with Consent Granted true.
  • Enable GTM consent mode support - if enabled, the tag will check for ad_storage, and if it is not granted, it will set the Facebook pixel consent to revoke. After the consent is granted, it will automatically execute fbq('consent', 'grant').
  • Limited Data Use (LDU) is an option for those needing to comply with various USA privacy regulations. When Meta receives data with this setting enabled from individuals, the platform will process it as a service provider or processor, as appropriate, and restrict its use as outlined in

3.6 (Optional) Object Properties - list the properties that will be sent to Meta with an event. See the list of Object Properties in Meta's documentation.

Server-side tracking - if you track the same event on server-side, configure this section by adding the Event ID parameter. It will allow deduplication of the same event if sent from multiple sources. Learn more about event deduplication in our blog post.

Configured Facebook Pixel tag

4. Add a trigger for a tag.

Click on "Preview" in the web GTM container. Trigger the event, and check whether it is fired.

Preview in GTM

Meta platform and server-side tracking

Server-side tracking helps track data more accurately, improving the conversion attribution as you can send data directly from your server to Meta's server in our context. There are a few options for setting up server-to-server tracking:

Both methods require cloud services for data processing and provide similar benefits in terms of data accuracy. The key difference is that Facebook CAPI provides higher flexibility, as besides Meta, you can set up server-side tracking for a list of other platforms. Facebook CAPIG is an easy-to-set-up solution that will be a great fit for those who need to track conversions only from Meta.

Read more about the differences between Meta CAPI and Meta CAPIG in our blog post. 

Summary

Integrating Facebook Pixel with GTM simplifies event tracking, allowing businesses to manage data collection from a single interface. Stape’s custom Facebook Pixel tag offers inheriting event data from the DataLayer or allowing manual overrides for precise customization. The tag's configuration is straightforward; you can integrate Meta Pixel with Google Tag Manager in a few simple steps.

author

Uliana Lesiv

Author

Uliana is a Content Manager at Stape, specializing in analytics and integration setups. She breaks down complex tracking concepts into clear insights, helping businesses optimize data collection.

author

Comments

Try Stape for all things server-sideright now!