Facebook Conversion Pixel for Google Tag Manager Server Side Tagging
Facebook Conversion Pixel for Google Tag Manager Server Side Tagging

Facebook Conversion Pixel for Google Tag Manager Server Side Tagging

With Facebook Conversions API, you can send events to Facebook Event Manager. That is the best alternative to Facebook SDK because Conversions API speeds up page loading and helps track users more accurately

There is a Facebook tag for the Google Tag Manager Server_Side container that uses Facebook Conversion API to track events.

DataFlow Process:

  1. User landed on Page
  2. gtag.js tracks ‘page_view’ event and sends it to GTM Server Side.
  3. GA4 Client on GTM Server Side receives the request and creates the EventData object.

Table of Contents

Setup Facebook Events Tracking

  1. Download the Facebook tag template from the GitHub repository
  2. Import Facebook server tag template into Google Tag manager Server Side container. Click on Templates -> Tag Templates ->. Then in the upper right corner, click on dots and choose import
Google Tag Manager Server side

3. Create a trigger that will fire on the GA4 client. Choose Client Name =”GA4″

4. Now we need to obtain Facebook API Access Token. There is the official documentation on how to get it.

5. Finally, we can create a Facebook Tag. Click on Tags -> New-> Tag configuration and choose Facebook tag.

6. Now you need to set the required tag configuration parameters (pixel ID, API Access Token). We recommend creating custom variables for storing Pixel ID, and API access token.

7. It’s ready, Now you can start sending test events

Testing Facebook Tag Google Tag Manager Server Side

Facebook provides the ability to test Browser and Server events. That is best to test when you set up Facebook pixel using GTM Server allows you to check that all data is tracked correctly.

  1. You need to obtain test_event_code. for this, you need to log into your Facebook manager, choose the data source that you liked to test, and open the tab “Test Events”. There you can find the event code.

2. Fill the Test ID field, in your Facebook tag, with the test event code that you get from the last step.

3. Go to Preview mode or publish changes to your server Side container. If done right, you will see test events on the Facebook Test Event page.

Event Name Mapping

By default, the tag tries to map GA standard events to Facebook standard events. If it is not matched, then the raw event name that came from the GA client will be used. For example, If you send an event name ‘event’:’select_item’ you will get the event ‘select_item’ in the Facebook events manager.

You can find the list of default events, and the schema mapping for GA events to Facebook events.

page_viewPageView
add_payment_infoAddPaymentInfo
add_to_cartAddToCart
add_to_wishlistAddToWishlist
sign_upCompleteRegistration
begin_checkoutInitiateCheckout
generate_leadLead
purchasePurchase
searchSearch
view_itemViewContent
contactContact
customize_productCustomizeProduct
donateDonate
find_locationFindLocation
scheduleSchedule
start_trialStartTrial
submit_applicationSubmitApplication
subscribeSubscribe

Google Analytics Ecommerce events to Facebook Events

To make the migration of your web Facebook GTM tag to the server-side container simpler, we tried to map all data that the 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 is mapped in every parameter group.

Default mapping and Overriding Server Events Data

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 available by default:

event_nameEvent Name
event_source_urlPage Location
action_sourceWhere your conversions occurred. (For example website, email, app)
event_timeCurrent Time

Default mapping and Overriding User Data

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 document calls for the parameter to be hashed, you must hash it with SHA256 or the hit will not be sent to Facebook.

fbcCookie value ‘_fbc’ or ‘fbclid’ url parameter if exist
fbpCookie value ‘_fbp’
external_idexternal_id or user_id or userId
subscription_idsubscription_id or subscriptionid
lead_idlead_id or leadid
lnlastName or LastName or nameLast
fnfirstName or FirstName or nameFirst
ememail
phphone
gegender
ctcity
ststate
zpzip
countrycountryCode

Default mapping and overriding Custom Data

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.

The tag also tries to determine other product parameters, including the following:

valuex-ga-mp1-ev or value
currencycurrency
transaction_idorder_id

All the parameters should be passed in and mapped to specified value types. As Facebook doesn’t accept some of the events like “Purchase” events without the currency parameters.

(Visited 558 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *