Setting up Facebook Conversion API via Google Tag Manager (GTM)

Last Updated: December 21, 2022

What is Facebook Conversion API and why do you need it?

Since the Apple IOS 14.5 update, many people have opted out of Facebook tracking.

As a result, your Facebook pixel cannot collect as much user data as it used to.

As the Facebook pixel collects fewer data about the users, the size of your custom audiences and lookalike audiences continues to shrink.

This has resulted in Facebook underreporting on conversions, events, ROAS and other results.

Many of the metrics used by Facebook Ad Manager for reporting purposes are no longer reliable.

To understand the full negative impact of the IOS 14.5+ updates on Facebook ads check out this article: The impact of Apple IOS 14.5 update on Facebook Ads

To mitigate some of the IOS updates’ negative impacts, Facebook recommends using the Facebook Conversion API (CAPI) along with your Facebook pixel.

The Conversions API helps improve performance by sending data you already share with your pixel through an API connection, which is less impacted by ad blockers and browser connectivity issues. You can see how people interact with your business in ways the pixel alone can’t measure, like when purchases are initiated online but completed in a physical store.” – Source: Facebook

How to make your Facebook pixel more powerful?

You should do two things to make your Facebook pixel more powerful:

#1 Manually feed your pixel with more conversion data.

Create a custom audience based on your customer list. Upload as much data as possible via the list.

You can use your shopping cart or CRM to get customers’ data. Make sure to supply conversion value.

Do this once every week to keep your custom audience up to date. Use this audience to create new lookalike audiences and then use them in your campaigns.

These new lookalike audiences are likely to be far more accurate than the one you have right now.

#2 Start using Facebook conversion API to collect server-based events.

Such events feed your pixel in the absence of corresponding browser-based events.

Facebook will prioritize Conversion API over Facebook Pixel.

Currently, browser-based events are prioritized to feed your Facebook ad pixel, and server-based events are used only in the absence of corresponding browser-based events.

But starting next year (2023), Facebook will prioritize Conversion API over Facebook Pixel.

That means that server-based events will be prioritized to feed your Facebook ad pixel, and browser-based events will be used only in the absence of corresponding server-based events.

What is required to set up the Facebook Conversion API?

Unless you are running and maintaining your own servers (server-side tracking), you won’t be able to use the Facebook Conversion API via GTM (Google Tag Manager).

So the first step is to deploy server-side tracking on your website via GTM.

Check out this article for more details: Server Side Tracking for Google Analytics via GTM.

This article will teach you to set up your GTM Server Side container, Google Cloud Account, and the three virtual servers (as recommended by Google).

Once you have set up all this, then come back and follow the instructions below.

How Facebook Conversion API works with Server Side GTM Container?

Facebook server side working

#1: When the user interacts with a website, a server request is made, and at the same time, the GA4 web tag fires on the client-side GTM container.

#2: This GA4 web tag then transports the data captured from the website (events, pageviews, variables) and passes it to the GA4 web client in the server-side container. 

#3: Now, the GA4 web client request is processed in the server-side container, and the related parameters are passed to the individual third-party server tags like Google Analytics 4 and Facebook.

#4: Once the required parameter is received in the Facebook Conversion API Tag, the data is finally dispatched to the Facebook server.

Now that you know how the Facebook tag works on the server-side container, let’s jump to configure it.

Configuration of the client-side GTM container

You need to configure the client-side GTM container to send values from the website to the GA4 client in the server-side container. 

This is done by using the ‘transport_url‘ field. I have explained this in great detail here: How to send data from a website to a server-side container

Since in this article we will talk about setting up the Facebook Conversion API tag using the basic GA4 tag, we will focus on the additional data parameters set up, as below. 

Updating general parameters

You may want to send many data parameters to Facebook, e.g. ‘Event Name’, ‘Page location’, ‘Event ID’ ‘, Ecommerce variables’, etc. We will configure those parameters first.

Note: I assume you have already created the required event tags, triggers, and variables in the client-side GTM container. 

If you need more information about how to create variables and use them, you can find it here.

As an example, I am going to configure the purchase event, which we will send to Facebook

Follow the below steps, to begin with:

Step-1: Navigate to the GTM client-side container and click on ‘Tags’.


Step-2: Now click on ‘Purchase event’.

Purchase event

Step-3: As you can see from the below image, I have already configured the purchase event, and it is being sent to the server-side container.

Let’s add a general parameter like ‘Page location’ to this event. 

Purchase event configuration

Step-4: Under ‘Event parameters’, click on ‘Add Row’.

Add row

 Step-5: Type ‘page_location’ under the parameter name and click on the + button beside the value text box.

page location

Step-6: Now select the variable ‘Page URL’.

page url

That’s it.

You are done! Just like we added the ‘page_location’ parameter, you can also add similar other parameters like:

  • Event_ID: If you want to identify each event uniquely.
  • Action_Source: Like website, application.
  • Campaign_Details: If you are tracking any campaigns.
  • Any other parameters useful to your organization that you would like to add.

Updating user data parameters

Along with general parameters, you may also like to pass a few user-related parameters to Facebook like ‘User Email Address’, ‘User City’, ‘User Phone Number’, etc. 

You may think this is PII (personally identifiable information), so how can we pass this in the GA4 tag?

But hold on, we will pass it to our server-side container and not to GA4 directly. We will filter out such variables in later steps. 

Step-7: To add user-related data parameters, click on ‘User Properties‘ and then click on ‘Add Row’.

user properties

Step-8: Now, type the parameter field you want to add.

For example, I am adding ‘user_data.email_address’ and then clicking on the + button to select the variable.

user property name

Step-9: Select the ‘User email’ variable from the list.

user email

And that’s it. Similarly, you can also add the following user-related variables.

  • user_data.phone_number
  • user_data.address.first_name
  • user_data.address.last_name
  • user_data.address.region
  • user_data.address.postal_code

Your final configuration may look like below

user data

Updating custom data parameters

Along with general and user-related parameters, you can also pass custom data parameters such as ‘transaction_id’ ‘value’, ‘currency’, ‘ecommerce variables’, etc. 

You can also pass facebook specific parameters like 

  • x-fb-ud-ge: Hashed user gender
  • x-fb-ud-db: Hashed user date of birth
  • x-fb-ud-external_id: External ID, e.g. advertiser loyalty ID with recommended hashing
  • x-fb-ud-subscription_id: Subscription ID, no hashing needed
  • x-fb-ck-fbp: Facebook cookies
FB parameters

Once you have added all the required parameters, the configuration at the client-side GTM container is done, and you can save the tag.

Configuring server-side GA4 Tag (exclusion of Facebook parameters)

Since we do not want to pass any PII data to the GA4 account, we need to exclude it from the GA4 tag in the server-side container. 

Follow the below steps to know more:

Step-1: Navigate to your server-side container, click on ‘Tags’, and then click on the GA4 configuration tag.

GA4 Tag server side

Step-2: In the tag configuration, click on ‘Events Parameters‘ and then click on ‘Add Row’ under ‘Parameters to Exclude’.

exclude parameters

Step-3: Now add all parameters that contain user-related PII data and Facebook-specific parameters.

excluded parameters

Note: If you don’t remember which parameters to exclude, you can put the server-side container in preview mode and generate a specific event. You will get all the information about the parameter name which needs to be excluded, like in the below image.

server exclude parameter names

Step-4: Save the tag, and you are done with configuring the GA4 server-side tag.

Configuring the Facebook Conversion API Tag

Now let’s set up the actual Facebook server-side tag. But, before you proceed to the set-up, let me tell you the requirements.

We will use the Facebook Conversion API Tag template here and need the parameters below.

  1. Facebook Pixel ID: To which we will send data. You can get this at
  2. API Access Token: So that we can interact with the API.
    Read more about API Access Token here:
  3. Test Event Code: Optional

Follow the below steps to continue.

Step-1: Navigate to your server-side container and click on ‘Templates’.


Step-2: Click on ‘Search Gallery’ under ‘Tag Templates’.

search galarry

Step-3: Select ‘Facebook Conversion API Tag’ and add it to a workspace.


Step-4: Navigate to the ‘Tags’ tab and click on ‘New’.


Step-5: Give your tag a name like ‘Facebook Conversions API Tag’ and click on ‘Tag Configuration’.

Facebook Conversions API Tag

Step-6: Now select the tag type as ‘Facebook Conversions API Tag’.

select tag type

Step-7: Now add your Facebook Pixel ID and API Access Token code. You can type ‘Test1234’ in the ‘Test Event Code’ and select ‘Action Source’ as a website.

FB tag configuration

Step-8: Click on ‘Triggering’ to create a trigger for our tag.


Step-9: Now apply the below configuration to your trigger:

  • Trigger fires on ‘Some events’
  • Condition: Client Name ‘equals’ GA4.
trigger configuration

Step-10: Save the tag, and you are done.

Preview and debug

Follow the below steps to preview and debug.

Step-1: Navigate to the server-side GTM container and click on ‘Preview’.


Step-2: A new window will open like the one below with a blank summary.

d4CVYTKqVTAQZmSkVF3zchTHRFvfV7ORGDOtXZ1lW7Oik6qevmY49cRZLCwxncDYeYSIgh0lSTt zZn4hTwAwbGKYsigvF sRBfC3PBvraG5gd kXfyjYw6vHyshjZpocrE sWMe

Step-3: Go to your website and perform the purchase event.

Once you do that, you should see that the purchase event is fired, like in the image below, and the Facebook Conversion API Tag has also fired.

purchase event in facebook

Step-4:  Now click on the ‘Request’ tab, and you should see the outgoing ‘HTTPS’ request to ‘ with status code ‘200’.


If you click on the ‘Post-200’ status code, you will get more details like below.

status 200 details

Now navigate to the Facebook Event testing tool and click on ‘Test Events’. You should be able to see the purchase event just like below.

FB live event


You have successfully set up the Facebook Conversion API Tag using the server-side GTM container.

Note: Like this purchase event, you can send any event from your website to Facebook using the server-side GA4 client and the Facebook Conversion API Tag. Just keep in mind to exclude the PII-related parameters from the GA4 server-side tag and to hash the necessary parameters.

  1. Server Side Tracking for Google Analytics via GTM
  2. How to Create Server Side Container for Google Tag Manager
  3. How to Configure DNS for GTM Server Side Container
  4. How to send data from Website to Server Side Container
  5. How to set up GA4 via GTM Server Side Tagging
  6. Google Tag Manager Tutorial
  7. How to set up Data Layer for GTM Server Side Container
  8. GTM Server Side Preview Mode – Tutorial

Frequently asked questions about GTM server-side tagging for Facebook tutorial. 

Can you set up Facebook Events using a server-side GTM container?

Yes, server-side tagging is a new way to use Google Tag Manager (aka GTM) in Google’s cloud environment. Using the Facebook Conversion API Tag, you can use a GA4 (in a server-side environment) client to send events to Facebook. 

You can use the below steps:

1. Configure client-side GTM container
2. Update general parameters
3. Update user data parameters
4. Update custom data parameters
5. Configure server-side GA4 Tag (exclusion of Facebook parameters)
6. Test the set-up
7. Configure Facebook Conversion API Tag
8. Preview and debug

What is the Facebook Conversion API?

The Facebook Conversion API allows you to send website events from the server-side GTM container to the Facebook Ads Manager or Events Manager. 

The conversion API is linked to the pixel and processes the event request like normal browser events. You can use these event details for reporting and optimization.

What is the Facebook API Access Token?

To use Facebook Conversion API, you need an access token. The access token is passed as a parameter in each API call and allows the conversion API to process the request and send it to Facebook.

Register for the FREE TRAINING...

"How to use Digital Analytics to generate floods of new Sales and Customers without spending years figuring everything out on your own."

Here’s what we’re going to cover in this training…

#1 Why digital analytics is the key to online business success.

​#2 The number 1 reason why most marketers are not able to scale their advertising and maximize sales.

#3 Why Google and Facebook ads don’t work for most businesses & how to make them work.

#4 ​Why you won’t get any competitive advantage in the marketplace just by knowing Google Analytics.

#5 The number 1 reason why conversion optimization is not working for your business.

#6 How to advertise on any marketing platform for FREE with an unlimited budget.

​#7 How to learn and master digital analytics and conversion optimization in record time.


My best selling books on Digital Analytics and Conversion Optimization

Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.

Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.

Attribution Modelling in Google Analytics and BeyondSECOND EDITION OUT NOW!
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.

Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.

About the Author

Himanshu Sharma

  • Founder,
  • Over 15 years of experience in digital analytics and marketing
  • Author of four best-selling books on digital analytics and conversion optimization
  • Nominated for Digital Analytics Association Awards for Excellence
  • Runs one of the most popular blogs in the world on digital analytics
  • Consultant to countless small and big businesses over the decade

Get My Step-By-Step Blueprint For Finding The Best KPIs (32 pages ebook)

error: Alert: Content is protected !!