Skip to content
Bach.ai

How to Install the Meta Pixel Using Tag Manager

Published
Drafted with AI; facts checked against the linked sources on . How we write

How do I install the Meta pixel with Google Tag Manager?

In Google Tag Manager, add a Custom HTML tag holding the pixel base code copied from Events Manager, set it to fire once per page on All Pages, then add one Custom HTML tag per event, such as Purchase with value and currency. Check the tags in Preview, click Submit to publish, then confirm in Test events.

Installing the pixel through Google Tag Manager takes two kinds of tag: one base code tag that loads on every page, and one small tag for each action you want Meta to count. Meta documents this route itself. The work that decides whether your data is right is not the paste, it is the triggers, the Purchase value and the check that nothing else on your site already fires the same pixel.

What do you need before you start?

Meta’s guide to adding the pixel with Google Tag Manager lists the prerequisites. You need:

  • Admin access to the Google Tag Manager account, with permission to create and publish tags.
  • A web container already set up for your site.
  • Access to Meta Events Manager or Business Suite, where you create the pixel and copy its base code.
  • A business portfolio in Meta Business Suite, if you manage several assets or datasets.

If you have no pixel yet, create one first: in Events Manager, click Connect data, select Web, name the pixel and click Create pixel (Set up and install the Meta pixel). One pixel ID can cover your whole website.

How do I add the pixel base code in Google Tag Manager?

These steps follow Meta’s own GTM guide (Add the Meta pixel with Google Tag Manager):

  1. Open Events Manager, select your dataset under Data sources, and click Add events, then Add new integration.
  2. Select Meta pixel, click Set up, choose Manually add code to your website, click Get started, then click Copy code.
  3. Log in to Google Tag Manager, select your website’s container and click New tag.
  4. Click Tag configuration, select Custom HTML and name the tag, for example “Meta pixel base code”.
  5. Paste the base code into the HTML field.
  6. Open Advanced settings and set Tag firing options to Once per page.
  7. Click Save, click Add trigger, select All Pages and save the tag to the workspace.

Google describes the Custom HTML tag as the way to deploy a tag that Tag Manager doesn’t yet support: you paste the code the vendor gives you into the HTML field (Custom tags). Nothing goes live until you publish the container, so you can build every tag before anyone sees a change.

How do I track purchases and other events through GTM?

The base code alone records page views, the pixel’s default event (Troubleshoot the event setup tool). Every other action needs its own tag and trigger. Meta’s steps (Add the Meta pixel with Google Tag Manager):

  1. Click Tags in the left menu of Google Tag Manager, click New and name the tag, for example “Meta pixel – AddToCart”.
  2. Click Tag configuration and select Custom HTML.
  3. Copy the event code from the Events Manager wizard and paste it, with variables for values such as product IDs, value and currency.
  4. Click Triggering, add a trigger, name it and choose the trigger type, such as Page view limited to some pages where the URL contains /product/.
  5. Save the tag and repeat for each event you track.

Meta has 17 standard events, from AddPaymentInfo to ViewContent (Meta pixel reference). For a store, four carry most of the weight:

Standard event Meta’s definition Required parameters Typical GTM trigger
ViewContent A visit to a page you care about, such as a product page None; contents or content_ids for catalog ads Page view where the URL contains your product path
AddToCart A product is added to the cart None; contents for catalog ads Click on the add-to-cart button, or a data layer event
InitiateCheckout A person enters the checkout flow None Page view on the first checkout page
Purchase A purchase is made or checkout is completed currency and value Page view on the order confirmation page

Source for the definitions and required parameters: Meta’s pixel reference. A Purchase without value and currency misses Meta’s spec and gives Meta no order amount to report, so map both to variables that hold the real order total, not a fixed number.

Make each event tag wait for the base code

Every event snippet calls fbq, which the base code defines, so the base code has to load first. GTM’s tag sequencing makes that order explicit: in the event tag’s Advanced settings, tick “Fire a setup tag before fires”, choose the base code tag, and optionally tick “Don’t fire if fails” (Tag sequencing).

How do I check the pixel is working?

Test in three places, two before you publish and one after, because each sees something different:

  1. Click Preview in Google Tag Manager, enter your site URL, click Connect, and confirm in Tag Assistant that the base tag and each event tag fired on the right pages (Preview and debug containers).
  2. Open Meta Ads Data Advisor, the Chrome extension, in that preview window and confirm the expected events fire on each page.
  3. Click Submit in Google Tag Manager to publish the container.
  4. Open Events Manager, select your dataset under Data sources, click Test events, open your website from there and walk through view, add to cart and checkout (Test events tool).

Meta says test events should appear within one minute; if they don’t, disable ad blockers and refresh the site (Troubleshoot test events). Website activity is only recorded while the Test events page is open, and data can take 30 minutes or more to show in your analytics. If Events Manager later reports no recent activity, work through why does my Meta pixel show no recent activity?

What if the pixel is already on the site another way?

Check before you publish, because a second install double-counts. Meta says duplicate Purchase events happen when the pixel runs through a platform app or site code and the same pixel ID is also added to Google Tag Manager (How to fix Meta pixel duplication). Its fix for Shopify stores is to keep the Facebook & Instagram channel and remove the duplicated events from GTM.

To find every copy, open a product page, open your browser’s developer tools, click the Network tab, search for your pixel ID and refresh. Any script other than Meta’s own that carries the ID is another install; Meta names GTM, Shopify, review apps and commerce platforms as common sources (How to find the source of pixel duplication manually). On Shopify, untangle the app and the GTM copy with why is my Meta pixel not firing on Shopify? rather than adding a third.

Should you also send events through the Conversions API?

Meta recommends it: when you share events with the pixel, it also recommends the Conversions API, which works alongside the pixel (Set up and install the Meta pixel). GTM users have a documented route. In Events Manager, Partner integrations, Google Tag Manager connects a server-side GTM container, hosted on Google or on Stape, that forwards data from the GA4 web tag to Meta (Integrate Conversions API with server-side Google Tag Manager).

When the same event arrives from browser and server, give both the same ID. In the pixel, that is the fourth argument, fbq('track', 'Purchase', {value: 12, currency: 'USD'}, {eventID: 'EVENT_ID'}), matched to the server’s event_id. Meta only deduplicates events received within 48 hours of the first one (Deduplicate pixel and server events). If counts still look doubled, use how do I diagnose duplicate events between pixel and CAPI? The wider setup is in the Meta pixel and Conversions API hub.

FAQ

Is there a Meta pixel template in Google Tag Manager?

Yes. A Facebook Pixel tag template for GTM is published on GitHub under Meta’s facebookarchive account. Meta’s Help Center guide still uses a Custom HTML tag, so that is the documented route. Whichever you use, run one installation per pixel ID.

Should the base code fire on every page?

Yes. Meta tells you to select All Pages as the trigger and Once per page as the firing option. The base code records page views and loads the pixel that every event tag depends on, so a page without it cannot send events.

Why does my Purchase tag fire but show no revenue?

Purchase requires two parameters, currency and value, in Meta’s pixel reference. A tag that sends only the event name, or a value variable that is empty on the confirmation page, records the purchase with no amount. Check the values in Tag Assistant and Test events during a real test order.

How do I remove a Meta pixel installed through GTM?

Meta’s steps: open the container that holds the pixel tag, disable or delete the tag, and publish the container. Then confirm with Ads Data Advisor that no pixel events fire. Removing the code stops events, but the pixel itself stays listed in Events Manager, because Meta offers no direct way to delete one.

Sources

Sources: Meta Business Help Center, Add the Meta pixel with Google Tag Manager, Set up and install the Meta pixel, Test events tool, Troubleshoot test events, How to fix Meta pixel duplication, How to find the source of pixel duplication manually, Integrate Conversions API with server-side Google Tag Manager, Remove Meta pixel code from your website; Meta for Developers, Meta pixel reference and Deduplicate pixel and server events; Google Tag Manager Help, Custom tags, Tag sequencing and Preview and debug containers; GitHub, Facebook Pixel GTM template (checked 2 Oct 2026).

MeasurementMeta Ads

See what your Meta ads are really costing you.

Connect your account and Bach ranks potential revenue leaks with estimates and actions you can review. Free for 7 days, no credit card.

Start Free Audit
Start your free audit