Magento 2 Facebook Conversion API: Step-by-Step Setup

Although you can add Facebook Pixel to Magento, ad blockers and cookie restrictions often prevent you from getting accurate data.  To avoid that, you need to set up Magento Facebook Conversion API — a smarter and more sustainable tracking.

In this guide, you'll learn what is the Facebook Conversion API, why you need it and how to set it up using the Magento 2 Facebook Pixel Extension by Magefan.

What is Facebook Conversions API?

Facebook Conversions API is a tool that allows you to send events from multiple channels from your server to Facebook Conversion API endpoints. This bypasses all browser technologies that block tracking and helps you get more reliable data about user behaviour across all of your channels.

In short, Facebook Conversions API creates a direct connection between your marketing data (website, app, CRM) and Meta technologies.

Why Do You Need Conversions API?

Facebook Conversion API is a technology that allows you to track data more accurately, so you can get multiple benefits, like:

  • Improved measurement — since all data sources are maintained from one connection point, it helps you quickly determine which channels are the most effective. This improves your measurement capabilities and gives access to more ad optimisation tools.
  • Robust targeting data — with Facebook Conversion API, no data is missed due to browser issues. So you get a higher volume of more reliable first-party data you can use to target the right people at the right time.
  • Decreased cost per results — the first-party data you collect helps you improve targeting and allows you to allocate your budget toward potential buyers.

Facebook Pixel vs Facebook Conversion API

Facebook Pixel and Facebook Conversion API work on the same thing —  transferring your marketing data to Facebook and delivering it to the same destination (Facebook Pixel). However, they differ in the way that data is collected.

The main difference between Facebook Pixel and Conversion API is that Facebook Pixel relies on the browser to deliver the data, while Conversion API uses the server.

Besides, Facebook Pixel focuses more on website data, while Conversion API allows you to track app and CRM events as well. 

So it's important to understand that you don't have to use either the Conversions API or the Facebook Pixel. You use both

In fact, there is no separate option for Conversion API when you create a new data source in the Events Manager. Facebook recommends you use both Facebook Pixel and Conversions API.

How to Set Up Facebook Conversions API for Magento?

Setting up the Facebook Conversion API for Magento requires you to create a dataset in the Facebook Events Manager with the Conversion API connection. Then you just paste the pixel ID and the API access toten into your Magento admin panel using the Magefan Facebook Pixel Extension. 

We'll go through the process step by step. 

Step 1: Create a new dataset

Start by navigating to the Facebook Events Manager. Then click on the +Connect Data option on the left, choose Web and click Next

connect new data source to facebook

Then give your dataset a Name and hit Create.

connect data facebook ads manager

In the next step, select the Set up manually option from the Recommended setup list.

set up facebook pixel manually

Important: Facebook requires you to confirm your email in the Business Account settings. If you haven't specified an email when setting up your business account for some reason, you won't be able to choose this option from the Recommended setup list.

Since we're setting up the Conversions API and Facebook Pixel, choose a corresponding method and move Next.

add facebook conversions api to magento

Facebook then offers you to set up the Conversions API and Facebook Pixel directly. Just click Finish, since with the Magefan Facebook Pixel, you don't need to copy the Pixel script or set up events for Conversion API. This extension will do it for you.

set up conversions api facebook

Step 2: Get Facebook Pixel ID

Once you finish, you'll get to the dataset overview. Switch the tab to Settings to find the Pixel ID under the pixel name or the Dataset ID field. Copy it.

facebook pixel data set id

Step 3: Generate Conversion API token

While still in the Setting tab, scroll down to the Conversions API > Set up direct integration. Choose the Set up without Dataset Quality API option and Generate access token.

Note: in both cases here — with and without the Dataset Quality API — events are triggered and sent to Facebook in the same way.


The only difference is that the Dataset Quality API offers some more metrics, which you can control directly from Facebook. Choose this option if you want extended metrics and generate the access token. In most cases, and for Magento specifically, the standard API is enough.

generate access token for facebook conversion api

This will generate a unique access token on the same page. Just copy it and move to the next step.

Step 4: Add your domain to the allowed list

Although you can add a Facebook Pixel ID and an access token for the Conversion API to Magento, Facebook must allow your website to send data to your dataset first. 

So, while you're still in the Settings tab of your dataset, scroll down to the Traffic permissions - Websites section and click Create allow list.

create allow list websites for facebook pixel

Paste your domain name in the corresponding field and follow the confirmation steps by clicking Next.

manage traffic permission facebook pixel

Once you do that, your domain appears under the Allowed list.

facebook pixel allow list

Step 4: Configure Facebook Conversion API in Magento admin

Finally, the most important part is implementing the Facebook Conversion API in Magento. For that, navigate to Stores > Configuration > Magefan Extensions > Facebook Pixel

Once there, enter your Facebook Pixel ID in the General section.

magento 2 facebook pixel id

Then enable the Conversion API and add the Access Token in the corresponding field. Save the settings.

facebook conversion api magento

The Facebook Pixel starts collecting your website events right after you save the settings. No need to create any events or do any extra steps on the Facebook side at this point. 

Step 5: Test Conversion API connection

To test how the Conversion API and Facebook Pixel work, go back to the Events Manager. Find the data source you've just created and move to the Test events tab. 

Choose to test the website's server events, copy the test code and run the test with the Graph API Explorer

test conversions api in magento

Then, verify the test event code and click Submit. If the return 'code' is 200, your server connection is active.

test conversions api facebook

Since it's the Facebook Pixel + Conversion API setup, choose the website testing option in the same tab.

Paste your website URL and trigger some actions on your store. They should be displayed in the Test events tab on the Facebook dataset with all the data that is being passed from Magento to Facebook.

test facebook events in ads manager

The other option is also to go to the Overview tab of your dataset and switch to Integrations. You should see both Facebook Pixel and Conversions API connected.

facebook pixel integration connected

Lastly, switch back to Event activities (within the Overview tab) and View details for any event. You should see the server event triggered.

customize product event facebook pixel

 

Now all you need to do is gather those valuable insights about user behaviour and use them to optimise your Facebook ads for the best results. Since the Facebook Conversions API offers more stable and reliable tracking, you should not miss any events. 

If you're also using data for Google Ads, you should check out our guide on how to set up Conversion Tracking in Magento.