Get 15% off Mageplaza extensions & subscriptions! Use code HIMAY at checkout.

How to implement Facebook Pixel in Magento 2

Jade | 02-20-2020

The Most Popular Extension Builder for Magento 2

With a big catalog of 224+ extensions for your online store

The social network algorithm’s update has a significant impact on the Facebook marketing world. To sustain engagement and drive traffic to a website through the platform, brands can’t ignore Facebook Ads.

If you’re running a Magento 2 online store and leveraging Facebook ads, have you ever wondered what’s happening with your ads or what people see on your site after clicking through your ads? You can find the answer by using Facebook pixel - an optimal analytics tool for your marketing strategy.

Learn more about Facebook Pixel and adding it to your Magento 2 website by an integration tool in this article.

Product Feed

Product Feed for Magento 2

Increase visibility and reach for products on various marketing channels (Hyva ready)

Check it out!

Table of Contents

Related posts:

What is Facebook Pixel?

Facebook Pixel is a piece of Javascript code that you add to your website. It enables you to track conversions from your Facebook ads, measure, optimize, build audiences for your ads, and retarget your website visitors. Facebook Pixel helps you maximize the performance of your ad campaigns by understanding the actions people take on your website across the devices. Using Facebook Pixel, you can ensure your ads expose to the right targeted audiences.

How does Facebook Pixel work?

Facebook Pixel is powerful as it measures the effectiveness of your Facebook advertising campaigns and enables you to reach relevant audiences.

Facebook Pixel gives you useful insights into your marketing campaigns. It collects data relevant to your Facebook ads, your website visitors, and customer data to track and measure your ad’s conversion rate. You will get to know where traffic is coming from, devices users use, and essential demographic information. After someone navigates to your website from an ad and takes specific actions such as placing an order, your Facebook Pixel will record the action as an event and report it in the Facebook Ad manager. After that, the tool reviews the conversion events to determine the exponential advertising strategies.

In particular, a Facebook Pixel can track:

  • Key page views
  • Product searches on your website
  • Add to cart/wishlist
  • Checkout
  • Add payment information
  • Purchases or checkout flow
  • Lead
  • Subscription, sign-up

You can take the best of Facebook Pixel for conversion rate optimization via Facebook. After collecting enough valuable Facebook lead and customer data, Facebook will expose your ads to people who are most likely to convert.

How to set up Facebook Pixel in Magento 2?

Step 1: Create Facebook Pixel

If you already have an old version of the conversion tracking pixel, you also need to create a new one as Facebook combined the conversion tracking pixel and the custom audience pixel into one Facebook pixel.

  • Open Facebook Ads Manager

Facebook Ads Manager

  • Find and choose Pixel tab, Click on Create a pixel

  • Enter the name of your pixel and your website URL (optional). Each account is allowed to create one pixel only. Upgrade to Business Manager to add more than one pixel.

  • Set up events and confirm

  • Get your Pixel ID for later set up.

Pixel ID

Connect your Facebook pixel with your Google Tag Manager account

  • Install your pixel code

  • Among three options to get the pixel code, choose Add code using a partner integration > Magento

connect website activity using pixel

Step 2: Install Magento 2 Google Tag Manager

If you host your website on Magento 2, we recommend Magento 2 Google Tag Manager extension - a viable tool to help you add a Facebook pixel quickly as the Facebook pixel seamlessly integrates into the module.

Google Tag Manager

Google Tag Manager for Magento 2

Easily monitor store stats and adjust marketing tags and snippets with simple source code

Check it out!

You can install and configure this Google Tag Manager for Magento 2 with ease.

Firstly, follow this guide to download and install the extension:

  • Log in to your Magento admin account, go to Stores > Configuration > Mageplaza extensions > Google Tag Manager > Settings.

  • Choose Yes to enable the module.

Magento 2 Google Tag Manager configuration

Secondly, get the Container ID to use for setting the Facebook pixel in Magento 2.

  • Visit your Google Tag Manager account, copy the Container ID.

Container ID

  • In the General configuration, enter the ID you get into Google Tag ID field.

Google Tag ID

  • Expand the Facebook Pixel section in your Magento 2 configuration. Enable the feature.

  • Choose the ID variable based on product ID or product SKU.

  • Enter the Pixel ID you get after creating your pixel into the Facebook Pixel ID field. If you leave this field blank or fill in incorrect ID, your Facebook pixel can’t track and report the data on your Facebook ads and your website.

Facebook Pixel

  • Save configuration. Facebook Pixel has been combined with your website successfully.

Step 3: Verify if your Facebook Pixel works

To check if your Facebook Pixel is integrated successfully with your Magento 2 store, you can install the Pixel Helper extension for Google Chrome. This extension will check whether your Facebook pixel is installed accurately, and pixel events run correctly.

When clicking on the Facebook Pixel Helper icon, the expanded panel will show warnings, errors, and successes. You will get to know your Facebook pixel works or not.


Facebook Pixel is a useful analytics tool that helps you measure your Facebook Ads, track conversion, and get significant insights into visitors for remarketing.

If you want to integrate Facebook Pixel into your Magento 2 store, it’s better to use an extension, like Magento 2 Google Tag Manager or Google Analytics , that includes Facebook pixel integration. You can create a pixel and add it to your store without too complex configuration or code.

If you’ve read this far, I hope you find this guide helpful and successfully integrate Facebook Pixel with your website. If you have any questions, feel free to leave a comment.

Explore Mageplaza Google Tag Manager

Related Posts:


Jade is a content creator, book lover, and a hodophile. She loves to learn skills and practical knowledge to excel at marketing, especially content marketing.

Related Post

Website Support & Maintenance Services

mageplaza services

Make sure your store is not only in good shape but also thriving with a professional team yet at an affordable price.