Setting up the Facebook Conversions API for server-side tagging

Blog cover: Facebook CAPI
In this article
Looking for a way to measure all your conversions without being dependent on third-party cookies? Meet the Meta Conversions API and discover how server-side tagging can be a future-proof game-changer for optimising your conversion measurement! In this blog article, I will primarily focus on setting up the Meta Conversions API via server-side tagging. I will discuss the benefits of server-side tagging and explain step-by-step how to implement the Meta Conversions API to be able to collect 100% of your conversion data. Whether you are a marketer, web designer, or e-commerce business owner, understanding and implementing the Meta Conversions API via server-side tagging can help you optimise your website and gain valuable insights. ‍

Wat is de Facebook Conversions API?

Meta always measured and stored data via a Facebook Pixel on a website. This made it possible for advertisers to apply personalised ads through Facebook. This was possible because Facebook Pixels were installed on so many sites that Facebook could track anyone on the internet anywhere to analyse and categorise everyone's behaviour, interests and entire customer journey. Thanks to Apple's iOS14 update in 2020, it was already no longer possible for Meta to collect data via the pixel on Apple devices. These updates change the way of data processing and cookie tracking, which means alternatives have to be found, so too for Meta. The Meta Conversions API (Application Programming Interface) is designed by Meta to maintain direct connection to user data even when they are not on a Meta platform such as Instagram or Facebook. Through the Facebook Pixel, data is sent to the user's browser and sent to Meta from there, but through Meta's Conversions API, data is first sent to a server and from the server, that data is sent back to Meta. Because the data is sent to a server, it is considered first-party data as opposed to third-party data.
By installing the Meta Conversions API, advertisers can bypass browser restrictions, but this does not solve all problems. In addition to browsers blocking conversion measurement, much data will also go unmeasured due to the intervention of ad blockers. Meta's Conversions API is a solution to continue measuring data, but for advertisers, it is not a complete solution. Furthermore, this API does not help with the continuously changing European data protection legislation (GDPR). The way to use the Meta Conversions API and to continue measuring all other blocked conversions is through Server-side tagging. By installing a tagging pixel on your website, you can bypass all ad blockers and process your data via Google Tag Manager. Server-side tagging can be set up via Google Cloud; you pay per gigabyte consumed for standard storage. With AdPage, we offer a cheaper alternative. Server-side tagging.  

What is AdPage Server-side tagging?

Server-side tagging is a method for collecting audience data. In contrast to client-side tagging, with server-side tagging, data is first sent to your own web server before being sent to a tracking platform like Meta, TikTok, or Google. The AdPage server-side tagging script is called first on a website, meaning conversions cannot be missed due to the intervention of ad blockers or browsers. Furthermore, you have control over which tracking platforms are allowed to read your data; you can choose what data you share and with whom. You have complete control over all the data you collect on your own server.  
By using a proxy server via server-side tagging, no third-party scripts are loaded, allowing your data to be sent directly to Google Tag Manager. This ensures compliance with GDPR legislation and provides protection for private data. By anonymising Personally Identifiable Information (PII) through server-side tagging, you can also build trust with your clients and consumers. This enables you to run profile-enriching campaigns, track your target audience, and measure conversions. Would you like to learn more about what server-side tagging is, and what the benefits are for you and your specific situation? Read on this blog article.  

Setting up the Facebook Conversion API correctly for server-side tagging

There are several ways to configure Meta's Conversions API. For example, the API can be set up on certain platforms like Shopify and WordPress with just a few clicks. However, if you want to set up the API via server-side tagging, there are a number of steps you'll need to follow. To be able to set up the Meta Conversions API within Google Tag Manager, you'll first need to be able to tag on both the web and server-side. With server-side tagging, the web container supplements the server container by processing data that would normally be executed in a browser. Therefore, the correct conversion tags within both the web and server containers must already be in place to set up the Meta Conversions API.

How do you set up the API for Shopify and other platforms?

Step-by-step guide to setting up Facebook's API

We understand that the paragraphs below may come across as gibberish. If you are not familiar with Google Tag Manager, we recommend you first this blog post to read.
First, you'll create a Google Tag Manager account with a web container and a server container. If you already have a Google Tag Manager account but no server container, then you'll just create a server container. Go to tagmanager.google.com and create an account.
Name the account and choose the country. Name the container and choose Internet as the target platform.
Within the same account, you will now create a new container again, this time a server container.
This time, you're choosing Server as the target platform.
Within the created server container, go to Administration and click on Set up Google Tag Manager.
Manually configure the Tag Server and copy the container configuration code.
Go to trytagging.com and create an AdPage Tagging account.
Create a new sGTM Container and paste the copied container configuration code into the correct box. Additionally, give the container a name and enter the correct domain; this domain is a subdomain, for example: tagging.myown.domain.
You will now need to link this tagging container to your own subdomain via DNS CNAME. Within trytagging.com you can see which subdomain you have created. The CNAME value is always projects.trytagging.com.
On trytagging.com you can now create the Tagging Pixel. Select the correct container and enter the WEB Container ID. You can find the WEB Container ID within your Tag Manager account. This is the Container ID of your web container.
This is now generating HTML code, which you can use both in the <head> as in the <body> on your site to place.

Purchase event via Shopify Webhooks

To measure conversions via Shopify, you will need to send the measured data to Tag Manager via webhooks. To do this, first go to settings and notifications within Shopify.
At the bottom of these settings, you can find the Webhooks.
As you can see in the screenshot above, a webhook has already been created. This webhook is activated by the “order creation” event and sends the data to the URL you see behind it in JSON format. You can also create this yourself by clicking on “Create webhook”. For the event, choose “Order creation”. For the format, choose “JSON”. For the URL, enter your tagging container URL with a recognisable slug, for example: “https://tagging.yourdomain.nl/order_created”. For the webhook API version, choose the latest option.
To enable this webhook to communicate with Google Tag Manager, you will need to use the correct template. We have prepared a number of templates that you can use within our helpdesk can find, including the Shopify webhook templates. Download the correct JSON file and upload it within your Tag Manager account. Within your server container, go to ‘Manage’ and ‘Import Container’.
Click ‘Choose container file’ to import the correct JSON file here.
Afterwards, select the correct workspace where you want to place the tags, variables, triggers, etc. This will most likely be an ‘existing’ workspace. Next, select whether you want Tag Manager to overwrite or merge your components. If you have (almost) nothing in your server container, choose ‘overwrite’. Otherwise, choose ‘Merge’ and then select ‘Rename conflicting clients, tags, transformations, triggers, and variables’.
Click ‘Confirm’. Now tags, triggers, variables, etc., have been automatically created. However, these still need to be supplemented with your data. In the new tag ‘Facebook Conversion API purchase’, the variables {{@FB Access Token}} and {{@FB Pixel ID}} are called.
Go to ‘Variables’ within your server container and find the ‘@FB Access Token’ variable. Within the variable configuration, it currently shows the value ‘FB token’, but this needs to be your Facebook Access Token. You can find this by selecting the pixel within Meta Events Manager and going to the settings. Here you will find the Conversions API section. Click on “Generate access token” and follow the steps in the pop-up.
Within ‘Variables’, click on the ‘@FB Pixel ID’ variable. Within the variable configuration, the value ‘PixelIDFB’ is currently shown, but this needs to be your Facebook Pixel ID. You can find this by opening your Business Settings in your Business Manager and clicking on Event Manager (Data Sources).

Conversion API Tag

Within your server container, you can also add a Facebook Conversions API Tag template to your workspace. Through this standard method, you will achieve slightly more results, but it will be less accurate than with webhooks. We recommend using the method described above and not this method. You do this by going to ‘Templates’, and here under the heading ‘Tag templates’ to ‘Search in gallery’.
You can find the Facebook Conversions API template from ‘facebookincubator’ via the search bar and add it to your workspace.
We are now going to add this tag template to a new Tag. You do this by going to ‘Tags’ and creating a new tag.
Give this tag at the top left a clear name, for example “Meta Conversion Tag”. Then click on ‘Tag configuration’ and select the Conversions API Tag as the tag type.
Under Pixel ID, you enter your Meta Pixel ID. You can find this by opening your Business Settings in your Business Manager and clicking on Event Manager (Data Sources). Under API Access Token, you enter your Meta Access Token. You can find this by selecting the pixel within Meta Event Manager and going to the settings. Here you can find the Conversions API section. Click “Generate access token” and follow the steps in the pop-up.
Click on ‘Triggers’ and then on the blue plus symbol in the top-right corner. Give this new trigger a name in the top-left corner, and click on ‘Trigger Configuration’. Select ‘Custom’ from the list of trigger types. Tick ‘Some Events’. The condition is that the ‘Client Name’ must be equal to ‘GA4’, assuming you have correctly set up the Google Analytics 4 configuration and tags in your Tag Manager account.
 
Save the trigger. Save the tag. As a test, you can use preview mode to see if you have set everything up correctly. Click ‘Preview’ in the top right corner. Your site will open, and when you perform an action that should be measured via GA4, you can see in preview mode that your Meta Conversions Tag is also being triggered. Would you like a more detailed explanation of the additional settings for the Meta Conversions API in Google Tag Manager, how to trigger conditionally and which parameters you can set? Then check out our Helpdesk article. Or do you have other questions about Server-side tagging, please get in touch via support@adpage.io.Would you like to get in touch with AdPage tagging specialists to see if your company needs Server-side tagging? Then schedule a demo below.

Curious how we can grow together?

Let's get in touch!

We'll review your situation and look at where the opportunities lie.

  • We'll look at your current tracking setup together.
  • Honest advice for tracking optimisation
  • Suitable for agencies and brands with their own webshop
No obligation
Bram en Jochem van AdPage