Facebook Pixel lets you track user activity on your site, collect remarketing audiences, and create lookalike audiences. When implemented correctly, the Facebook Pixel feeds relevant information to Facebook's machine learning algorithms (FB ML), which use this data to show your ads to individuals most likely to convert.

For several years, we have tracked events on our sites using JavaScript code, the Facebook SDK within apps, or by uploading offline events. But how do you track users with ad blockers, monitor events outside your site, or extend a cookie's lifetime? This can be achieved by implementing the Facebook Conversions API or the Facebook Conversions API Gateway.
This article will focus on Facebook conversion tracking and guide you on setting up the Facebook Conversions API via Google Tag Manager Server Container. Additionally, check out Stape’s pre-configured templates for Meta CAPI. Configuring your setup has never been easier; everything is pre-configured and ready for you!
| Related: Facebook Lead Ads. |
Let's take a look at what the Facebook Conversions API is and how we can use it to improve event tracking, attribution, and data collection on Facebook. The Facebook Conversions API allows you to send events directly from your server to Facebook's server.
Facebook CAPI serves the same purpose as the Facebook Pixel but relies on different technology. The policies and restrictions surrounding FB CAPI make it more suited to the needs of the modern tracking environment. Unlike the Facebook Pixel, the Conversions API does not rely on the user’s browser to send tracking information; everything is processed through the cloud server, enhancing data security and accuracy.
When examining the URLs of Facebook ads, you'll notice that FB appends an additional parameter, fbclid, at the end of almost any URL. The pixel code on the landing page stores this parameter's value in a cookie and sends it along with any Facebook event. In addition to the click ID (fbclid), Facebook uses the browser ID (fbp). The fbp and fbc cookies help Facebook identify the type of user who landed on your site and who converted.
Facebook can match users through other parameters such as email, phone number, first/last name. The more user data you send to the Facebook Conversions API, the higher your match rate will be.
Facebook server-side tagging, or the Facebook Conversions API, has been available for several years. However, starting in 2021, Facebook began to promote the Conversions API more aggressively. If you have a dedicated Facebook representative managing your ad account, they will likely recommend setting up the Facebook Conversions API.
Here are the most important reasons to consider implementing the Facebook Conversions API. See the details below.

By integrating the Conversions API alongside the Meta Pixel, Ray-Ban was able to significantly improve its advertising results. The combination led to a 36% greater reach on Facebook and Instagram compared to using the Meta Pixel alone.

Additionally, the brand saw a 19% reduction in cost per 1,000 views and a 7% decrease in cost per conversion, demonstrating the effectiveness of the Conversions API in optimizing their campaigns and driving better performance.
The Meta Conversions API Gateway is the fastest solution for implementing Meta server-side tracking and does not require any specialized knowledge.
The key feature of the Conversions API Gateway is its environment. Each Conversions API Gateway instance requires a cloud server to manage all communication processes between the Meta Pixel and the Conversions API. For a deeper understanding, check the Meta documentation on how the Conversions API Gateway works.
Once the Meta Pixel is connected to the Conversions API Gateway environment, it will use web events to track data from the server. Therefore, before implementing Conversions API Gateway, it's essential to ensure that web events are 100% accurate and contain all necessary user and product information before implementing the Conversions API Gateway.
With Stape, setting up and hosting the Conversions API Gateway is easier than ever. Simply create a Stape account and set up the Conversions API Gateway within Stape. Then, connect the required Meta Pixels to the Conversions API Gateway environment.
1. Low price. Stape hosting for Conversions API Gateway costs $10/month per pixel or $100/month for 100 pixels. We also offer a 7-day free trial.
Additionally, the Conversions API Gateway is the simplest way to implement the Conversions API, allowing you to save hundreds or even thousands of dollars compared to a manual implementation.
2. Easy setup. You don't need to hire developers or tracking specialists to set up the Conversions API Gateway. The setup process is straightforward and can take less than 1 minute, even for those without technical skills.
3. No maintenance. Updates for the Conversions API Gateway are installed automatically. There is no need to spend time manually updating settings or servers. Even when you add a new event, just set up proper web tracking, and the Conversions API Gateway will automatically start tracking events from the server.
1. New. The Conversions API Gateway is new, and Meta will likely roll out new functionalities and updates to the existing ones. Therefore, it makes sense to prepare for changes to its features.
2. No support for other platforms. If you want to take full advantage of server-side tracking, server Google Tag Manager (sGTM) might be a better solution. You will still need an instance of Google Tag Manager to manage server Google Analytics (GA), Google Ads, etc.
Stape offers hosting for the Conversions API Gateway at a cost of $10 per pixel per month or $100 for 100 pixels per month. Besides that, all users receive a 7-day free trial.

To set up Conversions API Gateway with Stape, all you need to do is:
Once you create the Conversions API Gateway container on Stape, we will set up an Amazon Web Services cloud formation stack based on Meta requirements and manage all updates.
For a step-by-step guide, please refer to our post on how to set up the Meta Conversions API Gateway.
| Check out our article on comparing Meta CAPI and Meta CAPIG to choose the right solution for your needs. |
One of the most accessible ways is to use server Google Tag Manager (sGTM). With sGTM, businesses can send customer data directly to Facebook's servers.
Pros of setting up Facebook CAPI via sGTM:
Cons of setting up Facebook CAPI via sGTM:
In this article, we will focus on configuring Facebook server-side tracking via server GTM.
We will use the server Google Tag Manager container to set up Facebook Conversions API. You will need these things to configure Facebook Conversions API:
We also have a blog post about the Tag Manager server container and its benefits on our blog.
This video shows how to set up Facebook Conversions API using Google Analytics 4.
2. Send data to the server GTM container. The two most popular methods for sending data to sGTM are Google Analytics 4 and Data Client Stape.
3. Go to your Google Tag Manager Server Container. Add the Facebook Conversions API tag from the Template Gallery.

4. Create a Facebook Conversions API Tag inside sGTM. Select Tag → Click New → Choose the Facebook Tag that you've added in the previous step.
Add your Facebook Pixel ID and Facebook API Access Token (we recommend adding it as a variable since you will need these values for each Facebook event you want to track). If you don't know your Facebook API Access Token, please refer to Meta's documentation.

5. You have 2 options for configuring our Facebook Conversions API tag:
6. If you've selected the override option, you’ll need to use GA4 or Data Tag/Data Client events to trigger Facebook server events. The Facebook pageview event should trigger on a custom event page_view that was claimed by a specific client (for example, if you chose to use GA4 as a data source for the Server GTM, then you should use the page_view event when the client name equals GA4).
To set up other events, go to sGTM preview mode, perform an action on your site that you want to track inside Facebook, and check the event name that GA4 or Data Tag sends to your Server Container.
In the screenshot below, we want to set up a Facebook event ViewContent when someone opens the product page on our site. Ensure you also send with your GA4 event / Data Tag from the web container any additional data you want to use for the server event. The example below also uses standard Facebook eCommerce parameters and user data.
To do that, we created a new tag inside the Server container, set it to override, selected the standard event ViewContent, added the API Access Token, and Facebook Pixel ID. We also added User Data and created a new trigger with the event name equal to view_item and Client Name equal to GA4.


7. You can pass custom parameters using the fields Server Event Data Override, User Data, and Custom Data. You can send user data to increase the matching score on Facebook via the User Data field. Note that the user information you want to send to the Facebook Conversions API should be hashed. Our Facebook tag automatically hashes the necessary data.
You can also enable Event Enhancement to use the HTTP-only secure cookie (gtmeec) in order to enhance event data. When this feature is enabled, the tag will store user data in cookies and enrich events with user data when it is not available. This way, you can increase event match quality, which can improve conversion attribution to campaigns.

8. When you are done setting up all your Facebook events, open Google Tag Manager debug mode and test if Facebook events work correctly. You can also go to your Facebook tag inside the server container and add the Facebook test ID. You can find the test ID inside the Meta Events Manager under the Test Events tab.

9. Once you've set up and verified that Facebook Conversions API works correctly, you need to remove FB browser tracking or set up event deduplication. Otherwise, your events will be duplicated.
The first step in testing Facebook server-side tracking is the same as for Google Analytics. You need to ensure that events are firing on the correct triggers. Open the GTM debug tool, navigate through your site's pages, and perform the events you want to test. Once you've done it, go to the Tag Manager debugger tab and check the results.
First, make sure that the FB base pixel is firing on a page view. If you see the tag status as Fail, check outgoing requests, which should indicate why the tag failed.

If you are using our FB server-side tracking tag, you have two options for sending FB events:
Open the Events Manager inside your Facebook Business Manager and click on Test Events. You will see a test event code that you should add to your Facebook Tag inside Google Tag Manager. This code will allow you to test Facebook server events in real time.
Once you've added the test ID, open your site and perform actions that trigger your FB events. Then return to the Facebook Testing Tool and check the events displayed. In the Received From column, you should see Server. You can click on the event to view the recorded parameters.

Note that the Facebook Pixel Helper Chrome plugin you used to check Facebook browser events won't work for the Conversions API. That's why you need to check everything in the testing tool.
Note: cookies will be extended only if you are using a custom subdomain inside the tagging URL. For example, your site’s URL is example.com, then a custom domain for tagging URL should look like gtm.example.com.
The third step is similar to what we did earlier, but with a few differences. To check the expiration date of the Facebook cookies, you first need to generate them. To do this, open your site and add fbclid.
Once you've done that, open the developer tools, go to Storage, and click on Cookies. Check that _fbc and _fbp have been extended.

With Stape, you can boost tracking accuracy and campaign results with server-side tagging.
Based on the platform you use, you can set up tracking quickly and effectively with our custom templates. Follow the step-by-step guides to set up Meta CAPI using server GTM for:
Templates and guides for Wix, Shopware, PrestaShop, and more are coming soon. Let us know if you need a template for another CMS.
Facebook recommends using both the Pixel and Conversions API to track events, but without event deduplication, duplicated data from the browser and server can skew results. Deduplication ensures that only one event is kept by using unique event IDs shared between both sources. Proper setup requires generating and syncing these IDs across browser and server events, which can be tested in Facebook's Events Manager.
Additionally, sending user data via the Conversions API improves match quality and event match scores, enhancing ad performance. User data should ideally come from a data layer and comply with privacy policies. Tools like Stape plugins simplify integrating user data for better Facebook campaign optimization.
To match users who visit your site with their database, Facebook uses User Data for the Conversions API.
Facebook requires you to hash some parameters before sending them, but you don't need to worry about that; Facebook's tag will automatically hash all the data before it's sent.
The more user parameters you send to Facebook, the higher the chances they will match a user, resulting in a higher event match score.
Sending user parameters from your site to Facebook is a sensitive topic since you'll be sharing user data with a third-party service. So before sending this data to Facebook, ensure it complies with your privacy policy.
Ideally, you should have the user data added to the data layer. If this isn’t possible, try to collect it from the page using custom JavaScript code and send it along with the conversions or events you are interested in.
For example all Stape plugins for CMS (for Facebook CAPI for Shopify, WordPress server-side tracking, Magento 2 Google Tag Manager, GTM app for BigCommerce) add a data layer that also contains user data.
You can easily retrieve it from the data layer and add this data to Facebook events in a web container.

Then, transfer the required data to the server container (in the payload GA4 or Data tag, depending on what you use).

Finally, add this data to your server-side Facebook event.

This way, you will achieve better match quality of your Facebook events, potentially improving the performance of your advertising campaigns, as Facebook will better understand your audience and optimize your advertising campaigns.
Facebook's Events Testing Tool is a powerful resource that allows you to debug and resolve issues with your Facebook Pixels or server events. If there are errors, they will be displayed in the Diagnostics tab on the toolbar for closer review.
Errors marked in red usually require immediate attention and should be fixed right away. Yellow errors are non-critical warnings that you should monitor and address eventually.
Facebook allows you to mark issues as resolved or ignore them. If you mark an error as resolved and it recurs, Facebook will show it again in three days. In contrast, ignored problems go to the Ignored section and remain there.
When you fix any issues with your Facebook tracking, we suggest marking them as resolved. This way, you notify Facebook that the problems were fixed, and the platform will alert you if these issues recur.

You can see all domains sending data to your Facebook Pixel. If Facebook detects traffic from a new subdomain or domain, it will send you a warning. You can whitelist or blacklist domains using this feature to block traffic from your testing sites or technical URLs.
Most likely, you will also see traffic from gtm-msr.appspot.com. This can happen when you run a debugging/publish container or when users visit your site with JavaScript disabled (some bots).
To create domain allow or block lists, open the Events Tool in Business Manager → click Settings → scroll down to Traffic Permissions.


This is the second most common Facebook CAPI error based on our experience. This error indicates that you are not sending some deduplication keys for your server events. Facebook uses these deduplication keys: event name, event ID, _fbp, and external ID.

From our experience, missing Event ID parameters cause this error 80% of the time. Check if you are sending an event ID for both the Facebook Pixel and the Facebook Conversions API. This event ID should be the same for both the browser and server events, enabling Facebook to recognize the same event name and event ID for deduplication.
For example, for PageView events, send the same event ID and event name from both the Facebook Pixel and Facebook CAPI.
To test the event ID, open the Facebook Event Testing Tool. If everything is correct, your output should look similar to the screenshot below. That is how Facebook shows it recorded PageView events from both the browser and server, which had the same event ID, indicating that browser events were processed and server events were deduplicated.

But there may be situations where you see browser and server events triggered randomly. In this case, check the Facebook event ID; they are likely not identical. You can use our custom variable for the web container to configure the Facebook event ID. For more information on Facebook event deduplication, refer to the section above.
Sometimes this error can occur if you did not remove the Facebook test ID and published the Facebook CAPI tags to the production environment. We recommend setting up Test ID as a lookup table variable that only functions when debug mode is enabled to resolve this issue.


Here, Facebook alerts you that the values being sent from the server are not unique or are incorrectly formatted. For example, you might be sending a user IP that includes symbols as well as numbers, or you may have selected the wrong variable, such as sending a phone number in the email field.
To identify the issue, open the preview mode of the Google Tag Manager server and web container (if you used GTM to set up Facebook Conversions API). You should see what user parameters were sent to Facebook and whether they were formatted correctly. Test the event, click on the tag in debug mode, and check the values.

This error may also indicate that you forgot to include a parameter or that it is incorrectly formatted.
For instance, there was a client who wanted to send the user's country and city based on their IP address. Facebook expected to receive actual user address details entered on the site, not those automatically extracted from the IP. This setup led to an error about invalid key parameters.

This error typically pertains to browser events and indicates that Facebook detected user data in the URL. Some CMSs and tools, like Calendly or PayPal, send user details in the URL after registration or purchase.
This error is difficult to resolve, and it requires your developers' attention. They should improve the URL query parameters and remove all user information from the URL. Alternatively, you can follow the Personally Identifiable Information (PII) removal instructions and attempt to fix the issue within GTM. Another option is to switch to server-side Facebook tracking only. This will allow you to modify the URL before sending it to Facebook.

For each server event you send to Facebook, an event match quality score is generated. This score depends on the amount of user data you send to Facebook.
If you use a custom subdomain for your tagging server, only the User IP, browser ID, _fbp, and _fbc are sent to Facebook's CAPI. Sending only these user parameters results in a match quality score of around 4 out of 10.
To achieve a high-quality score, it is crucial to send as many parameters as possible. Facebook uses this data to match users on your site with those in their database. But before proceeding, ensure that sending user data to Facebook complies with your site's privacy policy and relevant regulations. Technically, sending more parameters is beneficial, as it leads to more accurate audience and conversion data, provides Facebook's algorithms with specific information about your users, and improves campaign performance.
How can you increase the event match quality score? The answer is simple: send more user data. However, the implementation can be complex. First, check if the data layer is implemented on your site and whether it contains all user data. For example, if users can log in to your site, verify that user details are sent to the data layer upon login.
If the data layer is not implemented, assign your developers to set it up.
Next, ensure that you pass all user parameters from the web to the server container.
Additionally, a new feature from the Data Tag can help increase match quality. We have added the ability to store user data. For instance, if a user submits a contact form on the site, you can use the Data Tag to store user data in local storage and use it on other pages.
When tracking Facebook events from both the browser and server, Facebook requires a unique event ID for each event. For matching events, the Facebook Pixel event name must exactly match the server event name. The same applies to the event ID; events from the Facebook Pixel should equally match Facebook server events. This process is where deduplication occurs.
This error arises when you send the same event ID for multiple events. For example, when a user lands on the product page, two events should trigger: PageView and ViewContent. You must send a unique event ID for each event. The FB events and event IDs should appear as follows:
FB browser: PageView, eventID: ‘69’
FB server: PageView, eventID: '69'FB browser: ViewContent, eventID: '79'
FB server: ViewContent, eventID: '79'Even though these events trigger on the same page and might use the same trigger in the Google Tag Manager web and server container, you should send a unique event ID for both of them.
Same Event ID Received for Many Event Instances will occur if you’ll have this situation:
FB browser: PageView, eventID: ‘69’
FB server: PageView, eventID: '69'FB browser: ViewContent, eventID: '69'
FB server: ViewContent, eventID: '69'In this example, we are sending eventID 69 for both PageView and ViewContent events. But Facebook expects to see a unique eventID for these two events.
Solution: add Facebook test ID, open the preview mode of web and server containers, and test the setup. After you find out when this error happens, we can do more to fix the issue.
We created a custom variable that generates a unique event ID. I suggest using this variable to set up FB event deduplication. You can add an event name to this variable to ensure that the eventID is unique. In this case, even if your events will use the same trigger, the eventID will be unique since it consists of event_name_eventID. You can read more about Facebook event deduplication in the section above.
By default, the tag tries to map GA standard events to Facebook standard events. If it cannot match it, the raw event name that came from the GA client will be used. For example, if you send an event name like this: gtag(‘event’, ‘UserLikedProduct’), you will get the event “UserLikedProduct” in the Facebook event manager.
Below you will find the scheme of mapping GA events to Facebook events that we use in this tag by default:
| page_view | PageView |
| add_payment_info | AddPaymentInfo |
| add_to_cart | AddToCart |
| add_to_wishlist | AddToWishlist |
| sign_up | CompleteRegistration |
| begin_checkout | InitiateCheckout |
| generate_lead | Lead |
| purchase | Purchase |
| search | Search |
| view_item | ViewContent |
| contact | Contact |
| customize_product | CustomizeProduct |
| donate | Donate |
| find_location | FindLocation |
| schedule | Schedule |
| start_trial | StartTrial |
| submit_application | SubmitApplication |
| subscribe | Subscribe |
To make migration of your web Facebook GTM tag to server-side container simpler, we tried to map all data that GA client receives to the Facebook event without any setup from your side. It also supports GA Enhanced Eccomerce events mapping, and of course, the tag can override all event parameters that will be sent to Facebook.
For example, if the tag detects that the event type is “Purchase”, we will determine the product list, their currency, and value.
In the sections below, we describe how exactly data mapped in every parameter group.

There are only a few parameters that are in the category of Server Event Data. See this documentation for more details on what data parameters exist.
Parameters that are set by default:
| event_name | Event Name |
| event_source_url | Page Location |
| action_source | Where your conversions occurred. (For example: website, email, app) |
| event_time | Current Time |
With the “User Data” tag option, you can override or add any user data that will be sent to Facebook. See this Facebook documentation for more details on what user data parameters you can add to the call. If the documentation calls for the parameter to be hashed, you must hash it with SHA256 or the hit will not be sent to Facebook.
| fbc | Cookie value ‘_fbc’ or ‘fbclid’ url parameter if exist |
| fbp | Cookie value ‘_fbp’ |
| external_id | external_id or user_id or userId |
| subscription_id | subscription_id or subscriptionId |
| lead_id | lead_id or leadId |
| ln | lastName or LastName or nameLast |
| fn | firstName or FirstName or nameFirst |
| em | |
| ph | phone |
| ge | gender |
| ct | city |
| st | state |
| zp | zip |
| country | countryCode |
You also can override any other parameters or add your own using the “Custom Data” section in the tag setup. Check out this documentation for more details on what data parameters you can add to the call.
If the EE parameter ‘items’ exists, tag set content_type to ‘product’. GA product parameters item_name, item_category map onto Facebook content_name, content_category accordingly.
Tag also tries to determine other product parameters, including the following:
| value | x-ga-mp1-ev or value |
| currency | currency |
| transaction_id | order_id |
If the event type is “Purchase” but the currency can’t be mapped, ‘USD’ is used as the default value. That’s because Facebook doesn’t accept “Purchase” events without the currency parameters.
That’s it. We hope you’ve successfully moved Facebook tracking to the server. Facebook Conversions API is a great tool to get a better understanding of who your customer is, see the full customer journey up until the conversion takes place, and feed more data about your users to Facebook machine learning algorithms.
Stape has lots of options! Click on Try for free to register and check all the benefits.
Comments