Using Facebook server-side tracking (Facebook Conversions API) is getting more popular due to its ability to prevent tracking pixel blocking by ITPs and AdBlockers. Another massive benefit of Facebook conversion API is that it increases FB cookie lifetime. If you haven’t yet implemented FB Conversions API on your site, follow this guide.
In this article, I will describe how to set up Facebook events deduplication if you are using both browser and server tracking methods for your site.
The Facebook pixel and Conversions API lets you share standard and custom events with FB so that you can measure and optimize ad performance. The pixel enables you to share web events from a web browser, while the Conversions API lets you share web events directly from the cloud server.
Both Facebook pixel and Facebook conversion API let you send events. The difference is that pixel sends events from the browser, and CAPI sends events from the server. If you tell Facebook that the browser and server method send identical events, they will accept one and discard another.
There are several ways of setting up Facebook tracking, including the following:
If you decide to use both browser and server events tracking for all your events, in this case, you will need to set up event deduplication. With Facebook event deduplication, FB will receive all your events, understand that events are identical, clean some of them, and keep others. If you combine the browser and server method but do not set up event deduplication, your data will not be correct because all the events will be tracked twice.
Facebook requires sending two event parameters for event deduplication: its event name and event ID. You already sending the event name with the existing setup. This article will cover how to configure Facebook event ID inside the Google Tag Manager container.
Facebook has two way of identifying duplicated events that were sent from browser and server:
1. Event ID and event name.
Facebook recommends this method, and we will cover it in our how-to. For this method, you must use event ID for all events you send via pixel and CAPI. FB will deduplicate Facebook Pixels and Conversion API events with identical event names and event IDs. Facebook gives more credit to the browser event, and if they see similar events and come within 5 minutes difference, they will keep browser events and clean server events.
2. FBP or External ID
This method exists but is not recommended by Facebook. In this case, you will need to send the event name, fbp, and/or external_id for all your browser and server events. Facebook compares all these parameters and identifies if they already have a browser event with these parameters, and if they do, they discard server events. FB does not recommend using these events since they can identify deduplication only if the browser event was sent first. It means that if you send a server event first, events will be duplicated.
Facebook also can merge events. For example, if you send some enriched data from the server, you can add the missing data to the browser event. That is not a default feature. To enable it, you should contact a Facebook representative.
We created a custom Google Tag Manager variable that generates unique event ID you can use it in your web and server Facebook events. It will allow you to track users both from browser and server and deduplicate events. This method will work if your Facebook pixel is set up inside the Google Tag Manager Web Container and if Facebook conversion API is set up via Google Tag Manager Server Container.
1. You need to have Facebook conversion API setup via Google Tag Manager server container. Please follow this how-to if it’s not yet set up on your site.
2. Click on this link to download a custom variable that sends a unique event ID or add it using Template Gallery.
3. If you downloaded variable template from GitHub -> Go to your Google Tag Manager Web Container and import the variable that you’ve just downloaded. Click Templates -> New (inside the Variable Templates) -> click on the three dots on the top right corner -> import -> select variable -> When done, click Save. Go to the Variables tab inside the Web container -> Under User-Defined Variables click New -> create a Unique event ID variable using the template you’ve imported.
4. Add this variable to all Facebook tags you have inside the Web Container.
If you are using FB tag template:
Open Facebook Tag -> Click More Settings -> Add variable to the fields Event ID -> Click Save.
If you’ve added FB tags via custom HTML:
Open Facebook Tag -> add event ID parameter to the Facebook event -> Click Save.
eventID: ‘{{Event ID}}’
Follow the next steps if you use Universal Analytics. If you use GA4, please scroll down to step 9
5. We will configure a setup that will pass the same event ID to the Google Tag Manager Server container in this step. Since our Facebook server tag works based on the Google Analytics events, we will add Facebook events ID to Google Analytics tags inside the Web container. In this example, I will send an Event ID inside the Google Analytics Custom Dimension. You can send it via other fields.
Open Universal Analytics tag inside the Web container -> Click More settings -> Custom Dimension -> Add index and select Event ID variable.
Add Facebook event ID to all GA custom dimensions (or other parameters you’ve selected) that you want to track inside the server container.
Once you’ve done it, go to the preview mode and verify that everything works correctly. Then, Publish the updates.
6. Go to your Google Tag Manager Server Container -> Click Variables -> New Variable -> select variable type Query Parameter -> Parameter name cd1 (in my case because the index of the custom dimension that I’ve created in the web container is 1) -> Click Save.
7. Go to the Preview mode and check that the Google Tag Manager Server container sees the variable you’ve created.
8. Open Facebook Tag inside the Google Tag Manager Server Container -> Click Server Event Data Override -> in the Property Name select Event ID -> in the Property Value select variable that you’ve created in the server Container.
Add Event ID Variable to all Facebook tags inside the server container. Once the tag goes to the server preview mode, that test changes.
The next steps are for setup event id thru GA4. If you use Universal Analytics, please proceed to step 13
9. Create or use your existing GA4 event tag inside the Web container -> Event Parameters -> Add event_id as Parameter name and select Event ID variable as a value. Also, check what trigger you use for the GA4 event. You always should use the same trigger for Facebook tag and GA4 for identical events. For example, GA4 and FB add to cart tags should use the same trigger, in this case the vent ID will be identical. Add Facebook event ID to all GA4 event tags that you want to track inside the server container.
To reduce chances of the same event ID sent for multiple properties, you can add event name before the event ID variable. (similar to the screenshot bellow).👇
Once you’ve done it, go to the preview mode and verify that everything works correctly. Then, Publish the updates.
10. Go to your Google Tag Manager Server Container -> Click Variables -> New Variable -> select variable type Event Data -> Key path event_id (in my case because the parameter name that I’ve created in the web container is event_id) -> Click Save.
11. Open Facebook Tag inside the Google Tag Manager Server Container -> Click Server Event Data Override -> in the Property Name select Event ID -> in the Property Value select variable that you’ve created in the server Container.
Add Event ID Variable to all Facebook tags inside the server container.
12. Go to the preview mode and check that the event_id variable you created on the web container is the same as what you send to Facebook
.
13. In this step, we will verify that Facebook event deduplication worked. Go to the Test Event tool inside your Facebook Business Manager -> Make sure that you’ve added test ID to the Facebook tag inside the Google Tag Manager Server container -> Check that Facebook shows server and browser events in the testing tool and one of the events was deduplicated.
Make sure you remove test ID from Facebook conversion API tags after testing or set up a Test ID as a look-up table variable that works when debug mode is true. Otherwise, you might see a deduplication error in the FB events manager.
14. Don’t forget to publish your changes.
Facebook conversion API is an excellent solution if you want to track your site users more accurately, bypass ad blockers and ITPs, and extend cookie lifetime. With a combined server and browser method, you will still run Facebook pixels in the browser, making your site heavier. Using this method, you can be 100% sure that you did not miss any users or events on your site.
If you have some questions or comments about implementing Facebook event deduplication, please let me know in the comments.
We can help you right away! Click Get A Quote, fill up the form, and we will send you a quote.
Setting up the Facebook conversion API may be confusing. But after you did the tremendous job of moving FB tracking to the server and think that job is done, you might log in to your events manager the next day and see red and yellow warnings. In this blog post, I will describe the most popular Facebook conversion API errors and warnings. Plus, share some tips on how to fix it.
Aug 16, 2021Using Facebook conversion API, you can send events from your server to the Facebook server. Server-side tracking with configured custom subdomain helps to bypass ad blockers, ITPs, and iOS 14 restrictions.