Speed up your Magento store with Managed hosting. Use promo: MGT25 Avail Now
Magento 2 Tutorials

How to Add Facebook Pixel in Magento 2

facebook pixel magento 2

Facebook Pixel is a tracking tool will allow you to determine the effectiveness of your Facebook ads. You can easily check and analyze the actions and the way people interact with your ads and behave on your store as a result of the ad. The tool goes beyond that, though, and allows you to create retargeting audiences for your ads as well.

Every ecommerce can benefit greatly from Facebook Pixel by generating more sales. So today in this guide I’m going to teach you how to add Facebook Pixel in Magento 2. For this, I will use Facebook Pixel extension by Apptrian.

Steps to Follow

  • Download and Install Facebook Pixel Extension
  • Run CLI Commands
  • Configure Pixel Code in your Store

Download and Install Facebook Pixel Extension

Download the Apptrian’s Facebook Pixel extension from the Magento Marketplace. After downloading, go to the app directory from the root directory of your store and create directories: code/Apptrian/FacebookPixel. Unzip your downloaded extension file and upload it to app/code/Apptrian/FacebookPixel. The final directory will look like this:

facebook pixel directory

Run CLI Commands

Launch an SSH terminal and connect it to your store. Then go the root directory and run the following commands:

Enable the module:

php bin/magento module:enable Apptrian_FacebookPixel

Upgrade the setup:

php bin/magento setup:upgrade

Deploy static content:

php bin/magento setup:static-content:deploy

Clean and Flush the cache:

php bin/magento cache:clean

php bin/magento cache:flush

Configure Pixel Code in your Store

Open the admin panel of your store and then navigate to STORES → Configuration:

stores-config fb pixel

Click on Facebook Pixel under APPTRIAN EXTENSIONS:

click on facebook pixel

Then select Yes from Enabled and enter your Facebook Pixel ID:

configure facebook pixel


Now save the configuration by clicking on Save Config from top of the page:

save config fb pixel magento 2

It’s time to verify if Facebook Pixel successfully integrated to your Magento 2 store.

Install Facebook Pixel Helper extension to your Google Chrome browser. Launch your store and at the top of the browser you can see the icon of Facebook Helper extension. Click on the icon:

chrome extension icon

You’ll see this popup screen:

output facebook pixel m2

If the image above pops up, that means Facebook Pixel has been successfully integrated with your Magento 2 store!

Wrapping Up

Facebook Pixel is one of the best tools that can help you in getting large number of sales. After following this tutorial, I hope you can easily add Facebook Pixel to your Magento 2 store. If you still face any issue related to this tutorial, then just leave your query in the comment box below and I’ll get back to you!

Subscribe Newsletter

Subscribe to get latest Magento news

Experience Faster
Managed Magento Hosting