How To Setup Facebook Conversion API (cAPI) Tracking Using Google Tag Manager Server & Web Containers


The Facebook Conversion API allows you to send website conversion events directly from your server to Facebook.

This comes handy especially since the release of iOS 14.5 update, that made a lot of advertisers opt out of Facebook tracking.

As a result of the update, the Facebook pixel is no longer able to gather as much user data as before, which causes inaccurate reports on conversions, events, ROAS, and other performance metrics.

By integrating the Conversion API with Google Tag Manager’s server-side container, you will be able to track conversions properly without having any Facebook pixel code on your website. 

So in this step by step guide, I will walk you through the process of setting up the Facebook Conversion API using a Google Tag Manager server and web containers.

What is required to set up the Facebook Conversion API?

To setup the Facebook Conversion API alongside Google Tag Manager’s server-side container, you need to have the following:

  • An active Facebook ad account that supports the Conversion API.
  • An access token for the Conversion API.
  • A Google Tag Manager account configured with a server-side container

Once you have all this, then all you need to do is follow the instructions below.

How To Setup the Facebook Conversion API With GTM For WordPress Using Stape.io

You can easily set up Facebook conversion API for your WordPress site or landing page using Stape.io. 
With Stape, you get access to extensive solutions designed to simplify your server-side tracking setup for Google Tag Manager and Facebook Conversion API.

Set up server Google Tag Manager container

First go to you Google Tag Manager account, go to the Admin section and create a new Container:

Image25
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 32

Then enter a name for your server container, select Server as the type of container, and click the Create button.

Image24
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 33

Select the Manually provision tagging server option and copy the container configuration that you see. Save this configuration in a notepad as you will need it later.

Image2
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 34

Next you need to log in to your Stape.io account and click on Create Container.

Image13
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 35

Enter a name for your container, paste the Container Configuration that you copied from your Google Tag Manager Container, select the server location and click Create Container.

Image23
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 36

You need to wait a few minutes for the server container to deploy. Refresh the page after about 5 minutes to update the status. If the setup was done correctly, you should see the status “Running.” 

Image8
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 37

Next we need to set up a tagging URL. 

Here you can configure a URL using your own custom domain, or you can use your default URL that is hosted on Stape.io.

Image4
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 38

If you choose to go with your own custom domain, you can add it by clicking on the Add custom domain button. Then you’ll need to create a DNS record for the subdomain at your domain registrar.

For the DNS record, add these settings:

  • Type: A
  • Name: ss (or any other subdomain name you want)
  • IPv4 address: IP address depends on the location of the servers. You can find the custom domain IP address in your stape.io account.
  • TTL: Auto
  • Proxy status: disable

After that, you need to add your tagging server URL to your GTM server container. To do this go to the Admin section and select Container Settings. 

Image7
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 39
Image11
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 40

Setting Up The GTM Server Side Plugin In WordPress

Go to your wordpress dashboard, go to plugins and click Add New, search for the GTM Server Side plugin, then install and activate it.

Image17
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 41

Then open the plugin settings, and enter your Google Tag Manager ID, your tagging URL, and the Stape container identifier.

Image12
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 42

Setting Up Server Side GA4

Within your Web Container in GTM create a new Google Tag and add your Tag ID (GA4 Measurement ID), and in the Configuration settings enter the following parameters:

  • Name: server_container_url
  • Value: Enter the URL you’ve created
Image18
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 43

Then add a trigger to the GA4 tag. Normally it should trigger on all page views. 

Image6
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 44

You can set up a Google tag configuration settings variable to predefine Google Tag settings when using multiple Google Tags on your website. This saves you from manually adding settings for each tag.

These parameters can include settings like whether to send a page view event when a Google Tag triggers, setting UTM parameters and more.

Here’s a list of standard Google Tag parameters: https://support.google.com/tagmanager/answer/13438166

Next we need to set up the GA4 event. To do that you need to create a new tag and select Google Analytics: GA4 Event as the tag type, then enter your GA4 ID and the event name you want.

In our case it is going to be an Add To Cart event.

Image29
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 45

Next go to GTM Server Container, click Client and create a GA4 client and save it.

Image1
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 46

Then create a new GA4 tag, in the event name section select the variable you want add_to_cart in our case,

Image15
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 47

and add a custom trigger Client Name equals GA4.

Image9
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 48

Next open the Server container preview mode and make sure that you see GA4 requests, if yes publish.

Setting Up The Facebook Conversion API

A great thing about using Stape.io as your container is that it will map all standard Facebook events automatically. If there is a special event that stape can’t map, it will still record it as a custom event, so basically you don’t need to set up events manually.

Here are the standard events that Facebook supports:

  • PageView
  • AddPaymentInfo
  • AddToCart
  • AddToWishlist
  • CompleteRegistration
  • Contact
  • CustomizeProduct
  • Donate
  • FindLocation
  • InitiateCheckout
  • Lead
  • Purchase
  • Schedule
  • Search
  • StartTrial
  • SubmitApplication
  • Subscribe
  • ViewContent

To set this up, first you need to create a new Tag in your server container. Click add new tag, go to the community template gallery and add Facebook Conversion API Tag.

Image20
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 49
Image10
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 50

In the tag settings select inherit from client, and then you need to enter your Facebook API Access Token, Pixel ID and Test ID.

To generate an API Access Token, open your Facebook Business Manager account, go to the Events Manager, Data Sources, and click settings. 

Image19
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 51

Then scroll down and click Generate access token, and copy that.

Image14
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 52

Then copy your pixel ID and Test ID as well and go back to Google Tag Manager and fill out the requirements.

Image27
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 53
Image22
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 54

and go back to Google Tag Manager and fill out the requirements, save and that’s it.

Facebook conversion api
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 55

You also need to add a trigger. Click triggers, create a custom trigger, select ‘’This trigger fires on Some Events’’ and set Client Name equals GA4.

Image9 1
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 56

and go back to Google Tag Manager and fill out the requirements, save and that’s it.

Testing The Setup

Open the debugger for both the web and server Google Tag Manager containers, and then navigate through your website. In the server GTM container’s debugger, you should observe requests associated with the Facebook Conversion API Tag.

Image16
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 57

And of course you can test it using the Facebook Testing tool inside the business manager as well.

Image28
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 58

How to Add Landing Page Clicks as a Conversion Event on Facebook Ads using GTM Server

Now that you know how to set up the Facebook Conversion API tracking with GTM, you can set up all kinds of custom triggers you like in GTM and fire them back to Facebook as conversions.

In this example we are going to fire conversions on landing page button clicks with Google Tag Manager.

So first you need to set up the Click Button trigger. In GTM go to Triggers and configure a new trigger.

Then select Click on All Elements

Image3
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 59

And then configure the trigger by selecting the ‘’some clicks’’ option. Now you can set up different conditions for the event to fire based on your landing page or funnel, but the easiest way is by choosing Click Text from the built-in variables list:

Image30
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 60

So this way you can simply enter the text on your button, and when someone clicks on that button this trigger will fire the event.

Next when the trigger is set up, you need to add a tag to it, to send the event back to the Facebook conversion API.

For this we’re going to create a GA4 tag with the conversion event we want to send, for example Add To Cart. (This will only work if you have already set up the Facebook Conversion API and the GA4 client like we did in the steps above)

So click tags, create a new tag and in the tag configuration select Google Analytics and GA4 Event.

Image31
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 61

Then enter your GA measurement ID, the event name you want to send, and the Click Button Trigger you just created.

Image5
How to setup facebook conversion api (capi) tracking using google tag manager server & web containers 62

Click save and that’s it. Now you can go back and test it the same way we did above.

This way you can easily set up custom triggers for CTA buttons, or any buttons on your landing page, and fire conversion events on Facebook Ads.

Did you like this post? Please share it with friends to support this blog



We will be happy to hear your thoughts

Leave a reply

0
Your Cart is empty!

It looks like you haven't added any items to your cart yet.

Browse Products
Powered by Caddy
Shopping cart