To track Facebook (Meta) conversions with Google Tag Manager, add the Meta Pixel base code as a tag that fires on every page, then add one tag per standard event (ViewContent, AddToCart, InitiateCheckout, Purchase) fired by dataLayer events with the value, currency and product IDs. Then add the Conversions API and send each event from the browser and the server with the same event name and event ID, so Meta counts it once. On Shopify, skip the thank-you page script: use Shopify's Facebook & Instagram app or a custom pixel.
Which setup do you need?
Pick your path before you open GTM. The right one depends on your store platform more than on GTM.
| Your situation | Best setup | Why |
|---|---|---|
| Shopify store, you want it simple | Shopify's Facebook & Instagram app, data sharing on Enhanced or Maximum | Pixel and Conversions API in one place, no code |
| Shopify store, you already run GTM | A custom pixel (Customer events) that loads GTM | Thank-you page scripts no longer work |
| WooCommerce or a custom site | GTM web container for the Pixel, plus a Conversions API route | You control the dataLayer |
| Several tools need the same events (Meta, Google, others) | GTM web container plus a server-side GTM container | One data stream, many tags |
Use one path per event. If the Shopify app already sends the Pixel and you also add the Pixel in GTM, every event arrives twice.
What do you need before you start?
- Your Pixel ID from Meta Events Manager.
- A GTM web container installed on every page of the site.
- A list of the events you will track and the data each one needs.
- A consent setup if you sell where the law asks for it, so advertising tags only fire when people allow them.
- Access to a test order method (a discount code or a test payment), so you can check Purchase without guessing.
How do you install the Meta Pixel in GTM, step by step?
- Save the Pixel ID once. In GTM, create a Constant variable called
Meta Pixel ID. Every tag reads it from there. - Create the base tag. Use a Meta Pixel template from GTM's Community Template Gallery, or a Custom HTML tag with the base code Meta gives you in Events Manager. Google says gallery templates come from third-party developers, so check who maintains the one you pick.
- Fire it on all pages. Set the trigger to "Initialization - All Pages" or "All Pages". The base code must load before any event tag.
- Add one tag per event. Name them clearly:
Meta - AddToCart,Meta - Purchase. In each tag, open "Tag sequencing" and set the base tag to fire before it. - Fire event tags on
dataLayerevents, not on page URLs. A URL rule like "page contains /thank-you" fires again when someone reloads the page. - Test in GTM Preview before you publish (see the testing section below).
- Publish with a version name that says what changed, so you can roll back.
Don't install the Pixel in the theme code and in GTM at the same time. That also doubles every event.
Which events should an online store track?
Meta's Pixel reference lists 17 standard events. A store usually needs these five:
| Event | When it fires | Data to send |
|---|---|---|
| ViewContent | Product page view | content_ids, content_type, value, currency |
| AddToCart | Item added to cart | content_ids, value, currency |
| InitiateCheckout | Checkout starts | value, currency, num_items |
| AddPaymentInfo | Payment details added | value, currency |
| Purchase | Order confirmed | value and currency (both required), content_ids |
Use standard event names exactly as Meta writes them. Meta uses them for optimization and reporting; a custom name like "order_done" does not count as a Purchase.
How do you send purchase data with the dataLayer?
Your site (or a developer) pushes the confirmed order into the dataLayer once, after payment. Here is an example in the same format GA4 uses:
<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "purchase",
ecommerce: {
transaction_id: "ORDER_12345",
value: 129.99,
currency: "USD",
items: [
{ item_id: "SKU_1", item_name: "Black Hoodie", price: 79.99, quantity: 1 },
{ item_id: "SKU_2", item_name: "Cap", price: 50.00, quantity: 1 }
]
}
});
</script>
In GTM:
- Create Data Layer variables:
DLV - value(ecommerce.value),DLV - currency(ecommerce.currency),DLV - transaction_id(ecommerce.transaction_id) andDLV - items(ecommerce.items). - Create a Custom JavaScript variable
JS - content_idsthat returns the item IDs:
function() {
var items = {{DLV - items}} || [];
return items.map(function(item) { return item.item_id; });
}
- Create a Custom JavaScript variable
JS - event_idthat builds a stable ID from the order number:
function() {
var id = {{DLV - transaction_id}};
return id ? 'purchase_' + id : undefined;
}
- Create a Custom Event trigger with the event name
purchase. - Create the Purchase tag. In a Custom HTML tag it looks like this. Note that the event ID goes in the fourth argument, not with the other data:
<script>
fbq('track', 'Purchase', {
value: {{DLV - value}},
currency: {{DLV - currency}},
content_ids: {{JS - content_ids}},
content_type: 'product'
}, {eventID: {{JS - event_id}}});
</script>
If you use a template instead of Custom HTML, look for its "Event ID" field and put {{JS - event_id}} there.
Common mistakes: value sent as text like "$129.99" instead of a number, Purchase fired on the "Place order" click instead of the confirmed order, and the same push running again when the customer reloads the page.
How do you add the Conversions API without counting sales twice?
The Pixel runs in the browser, so ad blockers and browser limits can stop it. The Conversions API sends the same events from a server. Most stores send both.
Meta's deduplication rules are simple:
- Meta treats two events as the same when the event name and the event ID match: the Pixel's
eventIDmust equal the server'sevent_id. - It deduplicates events that arrive within 48 hours of each other, and keeps the first one in most cases.
- A second method uses
fbporexternal_id, but it generally works only when the browser event arrives first.
So build event_id from something both sides know, like the order number, and send it in both places.
Three ways to add the Conversions API
| Route | What you need | Good for |
|---|---|---|
| Platform integration (for example Shopify's Facebook & Instagram app) | Turn it on in the app | Stores on a platform with a built-in connection |
| Conversions API Gateway | A server in your own AWS or Google Cloud account; set up from Events Manager, no coding | Marketers with some technical skills and no developer |
| Server-side GTM | A GTM server container (Google Cloud or another provider), a GA4 client and Meta's Conversions API tag with an access token | Teams that already run GTM and want one data stream for many tools |
Whatever the route, test that the browser and server copies of Purchase carry the same name and ID.
What changed on Shopify?
Many old guides tell you to paste GTM or Pixel code in Shopify's "Additional scripts" box for the thank-you page. That no longer works. Shopify's help page says the Additional scripts section has been view-only since 28 August 2025, and that 26 August 2026 was the deadline for stores on non-Plus plans to upgrade their Thank you and Order status pages. Old customizations on those pages are replaced.
You now have two options:
- Shopify's Facebook & Instagram app. In Sales channels > Facebook & Instagram > Settings > Data sharing settings, choose a level. Shopify explains that Standard uses only the Pixel, while Enhanced and Maximum add the Conversions API. This is the easiest path for most stores.
- A custom pixel with GTM. In Settings > Customer events, add a custom pixel, paste your GTM code without the
<script>tags, and push Shopify's events to thedataLayer. Shopify's tutorial usescheckout_completedfor purchases. Keep in mind:- Shopify does not support custom pixels; you own consent, testing and updates.
- The pixel runs in a sandbox, and the "Troubleshoot tag" feature of Google Tag Assistant can't detect Google tags inside it. Test with Shopify's Pixel Helper instead.
- Standard Shopify events can't carry custom data; you publish your own events for that.
Use one option, not both, unless you turn off the Pixel in one of them.
Do you still need to set up Aggregated Event Measurement?
No. Old guides tell you to verify your domain and rank 8 events in Events Manager. Meta's help page now says you no longer need to prioritize 8 conversion events per domain, the Aggregated Event Measurement tab was removed, and you don't need to verify your domain for event configuration (you may still need it for other reasons). Meta adds that events sent through the Conversions API may also be processed under its limits.
How do you test the setup?
Check three places every time you change something:
- GTM Preview. Walk through the journey: product page, add to cart, checkout, test order. Confirm the base tag fires first and each event tag fires once.
- Variables in Preview. Open the Purchase event and check
value(a number),currency,content_idsandevent_id. - Events Manager > Test events. Confirm Meta receives each event with its parameters. If you run the Conversions API, check that browser and server Purchase show as one event.
Meta Ads Data Advisor, the free browser tool that replaced Meta Pixel Helper, shows which Pixel events fire on a page.
| Problem | Look first at | Usual cause |
|---|---|---|
| No Purchase in Events Manager | GTM Preview | The trigger never fired |
| Purchase has no revenue | GTM variables | value or currency not mapped, or sent as text |
| Double Purchases | Test events | Different event_id in browser and server, or the Pixel installed twice |
| Purchase fires on reload | Trigger | URL-based trigger instead of a dataLayer event |
| Events missing for some visitors | Consent settings | Consent denied, which is expected |
How to do this with SearchTheTrend
SearchTheTrend can't see anyone's conversions; only an ad account owner can. It helps you before and around tracking work:
- Open a competitor in Brands to see its store theme, apps and installed pixels, so you know how similar stores are set up.
- From any ad, go to its landing page and product, and compare your funnel with the pages that brands keep sending traffic to.
- Media buyers use days running, Ad Rank and spend in Europe to decide which ads to test once tracking works (see for media buyers).
Once events flow, read our guides on tracking Facebook ad performance and attribution models. Clean Purchase data also gives you better seeds for lookalike audiences.
FAQ
Can I install the Meta Pixel with Google Tag Manager?
Yes. Add the Pixel base code as a tag that fires on all pages, then add one tag for each standard event, such as AddToCart or Purchase, fired by a dataLayer event and filled with the value, currency and product IDs.
Do I still need the Conversions API if I use Google Tag Manager?
It is strongly recommended. Browser events can be blocked, while the Conversions API sends events from a server. Send both copies with the same event name and event ID so Meta counts the conversion once.
How do I track Shopify purchases with Google Tag Manager now?
Not with a script on the thank-you page: Shopify made the Additional scripts box view-only on 28 August 2025. Use Shopify's Facebook & Instagram app with Enhanced or Maximum data sharing, or a custom pixel that loads GTM and listens to the checkout_completed event.
How many standard events does the Meta Pixel have?
Meta's reference page lists 17 standard events. An online store usually needs five of them: ViewContent, AddToCart, InitiateCheckout, AddPaymentInfo and Purchase.
Do I still have to rank 8 events for Aggregated Event Measurement?
No. Meta's help page says you no longer need to prioritize 8 conversion events per domain, and you don't need to verify your domain for event configuration. Meta processes the events for you.