There are 2 ways to add Facebook Pixel to your Magento 2 store:
- Download & install the Facebook Pixel extension through Magento Marketplace. There are many Free Magento Extensions here. You can pick one for your website.
- Install manually using github
In this guide line, we are happy to introduce you a method to add Facebook Pixel to your Magento 2 store by using a third party extension.
Step 1: Download and Install the Facebook Pixel
The first thing that you need to do is go to the Magento Marketplace and download the Apptrian’s Facebook Pixel extension. Once you have downloaded this, you can visit the app directory from the root directory of your store. Then make directories: code/Apptrian/FacebookPixel. You can then unzip the extension file your downloaded. Upload this to app/code/Apptrian/FacebookPixel.
Step 2: Run the CLI Commands
The next step to adding a Facebook pixel to Magento 2 is to run the CLI commands. To do this, launch an SSH terminal. Then, connect this to your store. Visit the root directory and run a few commands.
To enable the module run this command:
php bin/magento module:enable Apptrian_FacebookPixel.
Next, to upgrade the setup, enter the following command:
To install the static content, you need the following command:
Finally, the last thing you need to do is clean and flush the cache. These commands will do this
php bin/magento cache:clean
Step 3: Configure the Facebook Pixel Code in Your Store
This is the final step to configure the Facebook pixel code in your Magneto 2 store. Go to Magento 2 admin panel >> Find STORES >> Configuration
You can then click on the Facebook Pixel You can find this underneath APPTRIAN EXTENSIONS. You can then hit YES from Enabled.
This is then when you will place your Facebook Pixel ID on the Magento 2 store. You can save the configuration by hitting the Save Config button which you can find on the top of the page. Once you have done all of this, you can then double check that your Facebook Pixel has been effectively combined to the website.
Step 4: Verify Your Facebook Pixel Has Been Successfully Integrated
The last thing that you will need to do is verify that the Facebook Pixel has been effectively combined to the Magento 2 store. To do this, install the Pixel Helper extension to Google Chrome. Then, launch the store and you’ll find the Facebook Helper extension icon . Hit this button and if the pop up appears then the Facebook pixel has been effectively combined.
Thanks for reading!