Research & Benchmarks Optimization AI Ads Analytics Why Madgicx? About Us Blog Careers Case Studies Events Glossary Guides Answers Pricing Login Try for Free

How do I add the Facebook (Meta) Pixel to Magento 2?

The usual way is Meta's Facebook & Instagram for Magento extension: install it with Composer, open the Facebook & Instagram tab in Magento Admin and connect your Meta pixel and ad account. If you would rather not install an extension, add the pixel through Google Tag Manager.

TL;DR

  • Meta's own extension is the main route for Magento Open Source and Adobe Commerce.
  • Installing needs developer access. Connecting needs Magento admin access and full control of your Meta business assets.
  • Test on a staging store first, as Meta recommends.
  • Check Meta's current Magento version requirement before you install, because Meta's pages list different minimums.
  • Google Tag Manager is the alternative when you want to avoid an extension.
  • Confirm events arrive in Events Manager, and avoid running two pixels at once.

What you need

  • A Meta pixel and an ad account in your business portfolio.
  • Full control of the business assets linked to the store.
  • Magento admin access, and developer access to staging and production if you install the extension.
  • A staging environment for a test run.

Two routes compared

Route Work needed Suits
Meta's Facebook & Instagram extension Medium: Composer commands and a connection flow Stores that want Meta's supported setup
Google Tag Manager Medium: tags and triggers, no extension Teams already managing tags in Google Tag Manager

Step 1: Check the requirements

Meta's Magento article says the extension works with Adobe Commerce On-Premise and Magento Open Source, and that you must have developer access to your staging and production environments to install it. The version minimum differs between Meta's pages: the help article says Magento 2.4.2 or later, and the extension's repository lists 2.4.4 or greater, PHP 8.1 or greater, and Magento's MSI (Multi-Source Inventory) modules. Read the current README before you install.

How to check: your Magento version, PHP version and MSI modules meet the minimum on the repository page.

Let Madgicx's AI do the work

Its AI marketer finds what's working and prepares the next move. You approve.

Try for Free ($0 Trial)

Step 2: Install the extension on staging

Meta's steps use Composer. Install the Meta Business SDK for PHP, then the extension, then run the setup commands:

  1. composer require facebook/php-business-sdk
  2. composer require meta/meta-for-magento2
  3. bin/magento setup:upgrade
  4. bin/magento setup:static-content:deploy
  5. bin/magento setup:di:compile
  6. bin/magento cache:clean

Meta says you may be prompted for Magento authentication keys. The extension is also listed on the Adobe Commerce Marketplace for Adobe Commerce cloud, Adobe Commerce on-prem and Magento Open Source, so choose the right edition and store version.

How to check: a Facebook & Instagram tab appears in the left menu of Magento Admin.

Step 3: Connect your Meta assets

Open the Facebook & Instagram tab and follow the connection flow. Log in with Facebook, choose Test to create a test shop or Production for your real shop, and select the business assets to connect. A test shop needs only an ad account and a Meta pixel. Meta recommends going through the onboarding stages on a staging environment with a test shop first, then again in production with your real shop.

How to check: the connection finishes and your pixel appears as connected.

Step 4: Decide on the Conversions API

Meta's article suggests you consider the Conversions API, which creates a direct connection between your marketing data and Meta. The extension's repository lists the Conversions API, the pixel and the catalog among what it supports. Our Conversions API setup answer explains the choices.

How to check: you know whether the pixel alone, or the pixel plus the Conversions API, is what you want.

Step 5: Test in Events Manager, then repeat in production

Open Events Manager, visit your store and browse a product. Meta recommends confirming that server events are firing and are deduplicated. Our pixel helper answer shows a quick browser check, and the Conversions API check answer covers the server side.

How to check: page views and add to cart events appear in Events Manager, one per action.

The other route: Google Tag Manager

If you manage tags in Google Tag Manager, Meta's guide says you can add the pixel there. You need admin access to your Google Tag Manager account, a website container, access to Events Manager and the pixel base code from Events Manager. Meta lists the benefits as centralized tag management and the ability to fix the pixel without editing site code.

Use one route, not both. A pixel added by an extension and a second one added by a tag would report each event twice.

What is the most common mistake?

Going straight to production. A staging run catches a missing MSI module, a version mismatch or a pixel that is attached to the wrong ad account before it affects live data.

What should I do next?

Put your key events through Events Manager, then decide whether to add the server side. If you changed themes or checkout, repeat Step 5.

Where Madgicx fits

Madgicx can do the server side for you. Madgicx Cloud Tracking hosts Meta's Conversions API Gateway and Signals Gateway and sends conversions to Meta from the server, so Meta sees and attributes more of your conversions. You stay in control of setup.

FAQ

Does Magento 2 have a built-in Facebook pixel?

Meta provides the Facebook & Instagram for Magento extension for it, and Google Tag Manager is the other route Meta documents.

Which Magento versions work with Meta's extension?

Meta's help article says 2.4.2 or later and its repository says 2.4.4 or greater, so check the repository's current README before installing.

Do I need a developer to install the extension?

Yes, for installation. Meta says you must have developer access to your staging and production environments to install it.

Can I test the connection without affecting my live store?

Yes. Meta recommends going through the onboarding with a test shop on staging first. A test shop needs only an ad account and a Meta pixel.

Is the extension also for Facebook Shops?

It can set up Shops and ads, or ads only. Meta notes that some Shops and checkout features are no longer supported.

Go deeper

For what each pixel event does once the pixel is running, read our guide to Facebook pixel events.

Sources

Official Meta Business Partner

Now you know how it works. Madgicx's AI does the work.

Madgicx is the agentic AI advertising platform for Meta ads. Its AI marketer finds what is working, prepares the next move and gets it done in one click, while you stay in control.

Try for Free ($0 Trial)
200,000+ advertisers
$10B+ annual ad spend visibility
4.6 / 5 on G2, from 220+ reviews