GTM Server Side Tagging for Facebook Tutorial

Table of contents for how to set up GA4 via GTM server side tagging  

  1. Working of a Facebook tag through the server-side container
  2. Configuration of the client-side GTM container
  3. Updating general parameters
  4. Updating user data parameters
  5. Updating custom data parameters
  6. Configuring server-side GA4 tag (exclusion of Facebook parameters)
  7. Configuring the Facebook Conversion API Tag
  8. Preview and debug
  9. FAQ

In this article, I will talk about GTM server side tagging for Facebook.

Note: This article is related to the server-side tagging articles below. If you haven’t read the earlier ones, I would highly recommend going through them. You can find them here:

  1. How to create a server-side container for Google Tag Manager
  2. How to configure DNS for a GTM server-side container
  3. How to send data from a website to a server-side container
  4. How to set up GA4 via GTM server-side tagging

Now let’s get back to our main article topic of setting Facebook tags via a server-side container. We will first learn more about how it works, and then we will do the actual implementation.

Working of a Facebook tag through the server-side container

I have tried to explain the working of the server-side Facebook tag through the below image and steps.

Facebook server side working

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

Step-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. 

Step-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.

Step-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 setup, as below. 

Updating general parameters

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

Note: I am assuming 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 them 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. Now, 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: Now type ‘page_location’ under 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 which are 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 be thinking that this is PII (personally identifiable information) so how can we pass this in the GA4 tag. But hold on, we will just 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. As an example, I am adding ‘user_data.email_address’ and then click 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 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 parameters 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)

Now 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 and 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, Facebook-specific parameters.

excluded parameters

Note: If you don’t remember which parameters to exclude, you can simply 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 for this.

We will be using the Facebook Conversion API Tag template here and we will need the below parameters.

  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: Now 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 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 be able to see the purchase event is fired like in the below image 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

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

Note: Just like this purchase event you can send any event from your website to Facebook using 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.

Related Articles:

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. You can use the GA4 (in server-side environment) client to send events to Facebook using the Facebook Conversion API Tag. 

You can use the below steps:

1. Configure of 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 setup
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 just 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
error: Alert: Content is protected !!