How to Add Facebook Pixel in Magento 2?

Getting your Facebook Ads to work is not a piece of the pie. Without accurate insights into customers' behaviour, setting up effective Facebook campaigns is going to be challenging. 

That's why you need Facebook pixel — a small piece of code that makes a huge difference. You add Facebook pixel in Magento 2, allow it to track information about different events customers perform on your website and send it to Facebook Ads Manager. 

It is easier than it sounds!

In this guide, we'll walk you through each step you need to take to make Facebook pixel work. You'll learn how you can set up a Facebook pixel in Magento 2 with no technical skills, using only Magento 2 Facebook Pixel Extension.

1. Install Facebook Pixel Extension

Unless you don't want to implement Facebook pixel tracking code directly into the source code, you need a little help. Install Facebook Pixel extension and you'll be able to configure everything from the admin panel in a few clicks.

2. Create a Facebook Pixel

To create Facebook pixel you need to go to Facebook Events Manager. Then find and click on the Connect Data Source (+) in the left flyout menu, choose Web and click Connect

Connect new data source in Facebook event manager

You'll be asked to Name your Pixel before you press the Create your Pixel button.

Note: it is recommended to choose a name that represents your business name rather than a specific campaign.

Create Facebook Pixel

Next, specify the website URL where you want to insert the pixel and let Facebook Check it. 

Check partner integration Facebook

Finally, you need to choose how to connect to your website. Select Meta Pixel only and click Next. If you like you can set up Conversions API later.

Connect website to Facebook pixel

3. Get Your Facebook ID

Although you'll be able to see your Pixel ID, at the final step of setting up the pixel, you need to know where you find it if you already have a Facebook Pixel.

To get Facebook Pixel ID you need to navigate to Data Sources at the left flyout menu in the Events Manager Account. 

Facebook event manager data sources

You might be asked to connect website activity using pixel. However, there is no need to do this manually or use partner integration since you just need to get your Facebook Pixel ID. Magefan Facebook Pixel Extension will do the rest.

Connect website easily using Facebook pixel

So, switch to the Settings tab and here's where you find your Pixel ID. Copy it and move to the next step.

Facebook Pixel ID

4. Paste Facebook Pixel ID into Magento Admin 

Once you get your Facebook Pixel ID, go to Magento admin panel > Stores > Configuration > Magefan Extensions > Facebook Pixel and paste it into the corresponding field. Don't forget to Save the settings.

Add Facebook pixel to Magento 2

5. Check Facebook Pixel 

To verify whether the Facebook Pixel is applied successfully and can track events accordingly, you need the Meta Pixel Helper extension for Chrome. 

Meta Pixel Helper

Add the extension and then go to the website you have installed the Facebook Pixel on. A popup will show how many pixels it finds on the page and whether they work properly. 

Meta pixel helper verification

6. Check Facebook Pixel Analytics

Before you check how your Facebook Pixel is performing, give it a few days. After some time, you can go to your pixel in Data Sources and check the overview of all activity and events for a certain period.

Facebook Pixel Analytics

Depending on your Facebook Pixel Extension Plan, you can track product page views, add-to-carts, add-to-wishlists, initiate checkout and purchase. 

Note: Facebook Pixel Extension from Magefan also enables you to track events per store view with different Facebook Pixel IDs. So, if you want to create personalized ads based on store views, give this extension a try.

Then you'll be able to create a custom audience for each event and set up personalized Facebook ads based on the gathered data.

However, that's now it. 

You need to make data-driven decisions not only when it comes to Facebook ads. If you want to enable dynamic remarketing for your store, you also need Magento Google Tag Manager.