How to add a Facebook pixel to Shopify
Updated
The fastest way to add a Facebook pixel to Shopify is to paste your pixel ID into a pixel app, which installs it through Shopify’s Web Pixels API in about a minute. You can also connect the official Facebook sales channel, or edit theme.liquid by hand. All three get the base code on your store, but only some of them survive a theme change and reach the checkout pages.
Quick steps
- Find your pixel ID. Open Meta Events Manager, select Data Sources, and copy the 15 or 16 digit ID shown under your pixel name.
- Choose an install method. Use a pixel app for multiple pixels or server-side tracking. Use the Facebook sales channel if you only need one pixel and already sync a catalog.
- Enter the pixel ID. Paste the ID into the app or channel. Do not paste the full base code snippet, only the numeric ID.
- Assign your events. Turn on ViewContent, AddToCart, InitiateCheckout and Purchase so Meta receives the full funnel rather than page views alone.
- Verify it fires. Load a product page with Meta Pixel Helper open, then place a test order and confirm the Purchase event appears in Events Manager.
Get your pixel ID from Meta Events Manager
Everything starts with the ID. In Meta Events Manager, open Data Sources and select your pixel. The number under the name, 15 or 16 digits long, is what Shopify needs. If no pixel exists yet, click Connect Data Sources, pick Web, and name it after the store so you can tell it apart later when you are running several.
A common mistake here is copying the whole base code block that Meta offers you. Shopify install methods want the numeric ID on its own. Pasting the full <script> block into an app field will either fail validation or install a second, duplicated pixel.
Method 1: the Facebook sales channel
Shopify ships an official Facebook & Instagram channel. Install it from the Shopify App Store, connect your Business Manager account, and pick the pixel during setup. It handles product catalog sync at the same time, which is why most stores start here.
The limit shows up quickly. The sales channel holds exactly one pixel. If you run ads through an agency, a partner, or a second ad account, there is nowhere to put the second ID. It also gives you no control over which events go to which pixel, so every ad account sees every event.
Method 2: editing theme.liquid by hand
You can paste the base code into theme.liquid just before the closing </head> tag. It works, and it costs nothing. It also breaks in ways that are hard to notice.
Theme edits do not carry over when you switch themes or when a theme update overwrites your file, so tracking quietly stops and nobody sees it until a campaign underperforms. The bigger problem is checkout. Shopify does not let you inject scripts into its hosted checkout, so a hand-pasted pixel misses the Purchase event on most plans. That is the one event your ad optimisation actually needs.
Shopify has also been phasing out script injection in favour of the Web Pixels API, and custom pixel code now runs in a sandbox. Manual snippets are on borrowed time.
Method 3: a pixel app
A pixel app registers through the Web Pixels API, which means it survives theme changes and reaches checkout, including Purchase. You paste the ID, pick the events, and you are done.
Pixelfy takes this route and removes the one-pixel ceiling at the same time. Add as many Facebook, Meta and Instagram pixels as you need, then decide per pixel which events it receives. An agency pixel can take Purchase only while your own takes the full funnel.
The setup that matters most is the Conversions API toggle. Browser-side tracking alone loses somewhere between a fifth and a third of events to ad blockers, Safari and iOS privacy settings. Sending the same events server-side recovers them, and event deduplication stops Meta counting both copies.
Verify the pixel actually fires
Install Meta Pixel Helper in Chrome and load a product page. You should see your pixel ID with a PageView and a ViewContent. Add the product to cart and watch for AddToCart.
Then place a real test order. Use a discount code for 100% off rather than a bogus card, because Shopify only fires the checkout events on an order that completes. Open Events Manager, switch to the Test Events tab, and confirm Purchase arrives with a value and a currency attached. A Purchase with no value is a Purchase your ad account cannot optimise against.
If events show up twice, you almost certainly have two install methods running at once. Remove one before you go further.
Questions
- Do I need a developer to add a Facebook pixel to Shopify?
- No. Both the Facebook sales channel and pixel apps ask only for your numeric pixel ID. The manual theme edit is the only method that touches code, and it is the method with the most drawbacks.
- How long before my pixel shows data?
- Events appear in the Test Events tab within seconds. The main Events Manager overview lags by roughly 20 minutes, and attribution reporting can take up to 24 hours to settle.
Related guides
- Facebook pixel not working on Shopify: 7 causes and fixes
Why your Shopify Facebook pixel shows no activity, misses purchases or fires twice, and how to fix each cause. Covers checkout, blockers and duplicates.
- How to run multiple Facebook pixels on one Shopify store
Shopify’s Facebook channel allows one pixel. Here is how to run several Meta pixels on one store, split events between them, and keep attribution clean.
- The Facebook Conversions API on Shopify
How the Meta Conversions API recovers Shopify conversions lost to iOS 14, ad blockers and Safari, what event deduplication does, and how to set it up.