How to install Facebook Pixel on Shopify with Google Tag Manager (all events, no app)
To install the Facebook Pixel on Shopify with Google Tag Manager, you add a data layer to your store as a custom pixel under Settings → Customer events, then build one Meta Pixel tag in Google Tag Manager for each event: PageView, ViewContent, AddToCart, InitiateCheckout and Purchase. Each tag reads the product, order and customer details from the data layer and carries its own event ID. No app is needed, and the same setup is ready for the Conversions API later.
The video above shows the whole setup on a Shopify store in about 17 minutes. This post is the written version: the steps in order, what to put in each tag, and the double-counting trap to check before you start. For a slower, field-by-field build of every tag, see my earlier video on the same setup.
Why Google Tag Manager instead of the built-in pixel
Shopify can install the Meta Pixel for you through Meta's Facebook & Instagram sales channel. It's quick, but you get little control. You can't choose what each event sends, and it's hard to debug when something looks wrong.
With Google Tag Manager, one container runs on your store and every tag, trigger and event lives inside it. You decide which details go with each event, you can test everything in Preview mode, and you never touch your theme code again. It's also the base you need for the Conversions API, which sends the same events from a server.
What you need
- A Meta Pixel ID. Meta now calls a pixel a dataset; the number is the same. This guide shows where it is in Events Manager.
- A Google Tag Manager account with a Web container for your store.
- A Shopify data layer script. It reads what happens on your store (product viewed, added to cart, checkout started, order placed) and pushes it to Google Tag Manager with the product, order and customer details. Without it, your tags fire with empty or incomplete data.
- Admin access to your Shopify store, to add a custom pixel.
The events this setup sends:
- PageView on every page.
- ViewContent when someone views a product.
- AddToCart when someone adds a product to the cart.
- InitiateCheckout when someone starts checkout.
- AddPaymentInfo when someone enters payment details (optional, but the data layer in the video sends it).
- Purchase when an order is completed. This is the one Meta uses most to find more buyers.
Before you start: check the Facebook & Instagram app
This is where most double counting on Shopify comes from. If Meta's Facebook & Instagram sales channel is connected to the same pixel with customer data sharing turned on, it already sends PageView, ViewContent, AddToCart, InitiateCheckout, AddPaymentInfo and Purchase. At the Enhanced and Maximum data sharing levels it also sends purchases through the Conversions API (Shopify Help Center, Meta data sharing).
Add your Google Tag Manager tags on top of that and every event reaches Meta twice, each copy with a different event ID. Meta can't tell they're the same event, so your purchases look doubled.
Check it in Shopify under Sales channels → Facebook & Instagram → Settings → Data sharing settings. Pick one source of Meta events for each pixel: either the app or your Google Tag Manager setup, not both.
Shopify also says to remove any old pixel code from theme.liquid and from the checkout's Additional scripts before you add a custom pixel, so events aren't counted twice (Shopify Help Center, manage custom pixels).
Step 1: get your Meta Pixel ID
If you already run Meta ads, you almost certainly have a pixel. Use that one; don't make a new one.
If you don't have one, open Events Manager, choose Connect data, then Web, and create a new dataset with a name. Copy the ID it shows. You'll paste it into Google Tag Manager in Step 5.
Step 2: create your Google Tag Manager container
Go to tagmanager.google.com and click Create account. Use your brand name as the account name and pick your country. For the container, use your store's name and choose Web. Accept the terms, and Google Tag Manager shows your container ID, which starts with GTM-. Keep it handy for the next step.
Step 3: add the Shopify data layer as a custom pixel
In your Shopify admin, go to Settings → Customer events and click Add custom pixel. Give it a name, such as "Shopify data layer", and click Add pixel.
Before you paste any code, set the two Customer privacy options:
- Permission. In the video I choose Not required, so the pixel runs without waiting for consent. That suits a store without visitors from places with strict privacy laws. If you sell to the EU or UK, choose Required and let your consent banner decide.
- Data sale. In the video I choose the option that says the data collected doesn't qualify as data sale. Check what fits your business.
Then clear the placeholder code, paste in your data layer script, and replace the Google Tag Manager container ID inside the script with your own. Click Save, then Connect. Shopify says a saved pixel doesn't track anything until it's connected (Shopify Help Center, manage custom pixels).
Google Tag Manager now runs on your store through Shopify's customer events sandbox. That includes the checkout and the thank-you page, which the old method of pasting code into theme.liquid couldn't reach properly.
Step 4: create the variables and triggers
Google Tag Manager has three building blocks, and the order matters:
- Variables read the data: product name, price, order value, customer email.
- Triggers decide when something fires: a product view, a completed purchase.
- Tags do the work: when this trigger fires, send this event to Meta.
Tags depend on triggers, and triggers depend on variables, so build them in that order.
Variables. Create a Data Layer Variable for each value your data layer sends: value, currency, transaction ID, item IDs, item names, contents, number of items, and the customer's email, phone, first and last name, city, state, zip code, country and external ID. Two more help a lot:
- A Constant variable holding your Pixel ID. If the ID ever changes, you change it in one place.
- A unique event ID variable that makes a new ID for each event. This is what lets Meta deduplicate later.
Triggers. Create a Custom Event trigger for each event name the data layer pushes. The event name must match exactly. If the data layer pushes purchase, the trigger listens for purchase. With the data layer in the video, the triggers are view_item, add_to_cart, begin_checkout, add_payment_info and purchase, plus a page view trigger.
Step 5: build the Meta Pixel tags
Create one tag per event. In the video I use the Facebook Pixel tag template by Stape from the Community Template Gallery, not a Custom HTML tag. It keeps the setup clean, and the same template supports a server-side connection later.
Open the Purchase tag first, because it's the most important one:
- Facebook Pixel ID: your Pixel ID constant variable.
- Event: standard event, Purchase.
- User data (advanced matching): email, phone, first name, last name, city, state, zip code, country and external ID, each from its data layer variable. Meta's documentation says the pixel hashes these values with SHA-256 before they're sent (Meta, advanced matching).
- Object properties:
value(the real order total from the data layer, never a fixed number),currency,content_ids,contents,content_type,num_itemsandorder_idset to the Shopify order ID. - Event ID: your unique event ID variable.
- Trigger: the
purchasetrigger.
The other tags follow the same pattern, with fewer details:
- PageView: Pixel ID, external ID, event ID. Trigger on all pages.
- ViewContent and AddToCart: add
content_ids,content_name,content_type,content_category,contents,valueandcurrency. Usecontent_typeproduct for a single product, or product_group if your products have variants such as size or colour.contentsis needed for catalog ads. - InitiateCheckout and AddPaymentInfo: the same, plus
num_items.
Two details matter for the Conversions API later. Every tag needs the event ID, because Meta pairs a browser event and a server event by the same event name and the same event ID (Meta, handling duplicate pixel and Conversions API events). And the order_id is worth sending, but it's the event ID that Meta uses to deduplicate, not the order ID.
Step 6: publish and test in Preview mode
Click Submit, give the version a name such as "Meta Pixel setup v1", and click Publish.
Then click Preview, enter your store's address and connect. Go through the store the way a buyer would: open a product, add it to the cart, start checkout, fill in the contact and shipping details, and place a test order.
In the Preview panel, open Tags Fired. You should see each Meta tag: PageView, ViewContent, AddToCart, InitiateCheckout, AddPaymentInfo and Purchase. A tag you didn't trigger, such as Search if you never searched, won't fire. That's expected.
The Meta Pixel Helper Chrome extension shows the same events on the page, with the contents, value, currency and external ID each one carried. Shopify's own Shopify Pixel Helper shows whether events reach the customer events sandbox without errors.
Step 7: check the events in Meta Events Manager
Events Manager is the source of truth. Open your pixel, go to Test events, choose Website, and repeat the journey.
You should see PageView, ViewContent, AddToCart, InitiateCheckout, AddPaymentInfo and Purchase arrive from the browser. Click the Purchase event and check what Meta received: the event ID, value, currency, content IDs, contents, order ID and the advanced matching details.
You may also see an event you didn't set up. In the video, Shopify sent one on its own when the buyer ticked the box to get email news and offers at checkout. It isn't a Meta standard event, and you can ignore it.
Events can take a while to show on the Overview tab. Test events is the quick check.
Next step: add the Conversions API
What you've built runs in the browser only. Ad blockers, browser privacy rules and iOS settings still stop some of these events from reaching Meta. The Conversions API sends the same events from a server, and because every tag already has an event ID, Meta can count each event once. Here's how: set up the Facebook Conversions API with Google Tag Manager.
Common mistakes
The Facebook & Instagram app still sends the same pixel. Two sources mean two copies of every event with different IDs, and doubled purchases. Keep one.
The trigger name doesn't match the data layer. Purchase and purchase are different event names. If a tag never fires, compare the trigger's event name with what the data layer pushes in Preview mode.
The custom pixel was saved but not connected. It won't track anything until you click Connect.
No event ID on the tags. The pixel works without one, but when you add the Conversions API, Meta can't pair the browser and server events, and purchases get counted twice.
A fixed value on Purchase. The value must come from the data layer, so each order sends its real total and currency.
The pixel ID typed into every tag. Sooner or later one tag gets the wrong number. Use a constant variable.
Questions people ask
Can I install the Facebook Pixel on Shopify without an app?
Yes. That's what this setup does. Google Tag Manager runs as a custom pixel under Settings → Customer events, and your Meta tags live in Google Tag Manager. No app or theme code is needed.
Should I use the Facebook & Instagram app or Google Tag Manager?
Either works, but not both for the same pixel. The app is quicker to set up. Google Tag Manager gives you control over every event and what it sends, and makes the Conversions API easier to add your own way.
Does the pixel track purchases on Shopify's checkout?
Yes, when it runs as a custom pixel. Shopify's customer events cover the checkout and thank-you pages, which theme code can't reach.
Do I need the Conversions API as well?
For most stores running Meta ads, yes. The browser pixel misses some events. The Conversions API sends them from a server, and the event ID you added here stops them being counted twice.
Where KiteTrack fits
KiteTrack takes this setup the rest of the way. It runs your own tracking server on your store's subdomain and sends your Shopify events to Meta through the Conversions API, next to the pixel, with one event ID so each sale counts once. The same server sends to Google Ads, GA4 and TikTok, customer details are hashed before they leave it, and your tracking is checked every 30 minutes, so a broken event becomes an alert. See how it works for Meta on Shopify.
Not sure whether your pixel is sending what it should? Start with the free Tracking Check. It looks at your site in about two minutes, no signup. If you'd rather talk it through, book a call with me.
Sources
- Shopify Help Center, Manage your custom pixels: https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels/manage
- Shopify Help Center, Meta data sharing: https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing
- Meta, Advanced matching (Meta Pixel): https://developers.facebook.com/documentation/meta-pixel/advanced/advanced-matching
- Meta, Handling duplicate pixel and Conversions API events: https://developers.facebook.com/docs/marketing-api/conversions-api/deduplicate-pixel-and-server-events/
Get tracking tips by email
Short, practical fixes for Meta, Google Ads and GA4, from Abir.
You’re in. First tip lands soon.