How to set up event collection in GTM to get ready for Facebook Conversion API
This document describes the prerequisites that need to be done inon Google Tag Manager in order to prepare an export to Facebook Conversion API.
The reason is that the event ID should be the same for the Meiro Event tracking function and the same for the Facebook tracking function for every event.
Users need to define id in various ways:
- Uuid or external uuid library,
- A mix of form id and timestamp when it was sent and pass it to both functions.
If that is set correctly,correctly data analysts can sync the basics of this function.
Warning: Each event needs to have a unique event id
.
TheHere mainare pointsthe are:steps to take:
- Define one tag for each event e.g.
transaction
oraddToCart
event. Here is a list of standard events you can explore or you can set your own custom event. It is recommended to have the same event name andevent_id
as the Meta Pixel for event deduplication purposes. - Generate uuid or some other unique
event_id
identifier. - Send both events, MeiroEvents.track(…) & fbq('track'…) and use the same generated
.event_id
- Recommended to add
event_name
in the payload for MeiroEvents.track(...) as one of the custom fields. Theevent_name
needs to match the event being tracked by theFBMeta Pixel in fbq(‘
, ‘tracktrack’event_name
event_name
from Meiro events when sending it to the FB Conversion API. Without this in the payload, there needs to be predefined logic to map Meiro events to the trackedFBMeta Pixel event name. - At least one customer identifier is needed, such as email in the payload.
Remember: If the customer identifier cannot be added to the payload, we can ingest the conversion events and run it through profile stitching in order to obtain an identifier. However, this will result in longer man hours for data processing (ingestion, profile stitching, attribute calculation).
Learn more: about customer identifiers here.
6. Inform your Meiro contact on the following:
- List of events implemented with the exact event name
- Associated Meta pixel
Learn more: about FBMeta Pixel and server event deduplicationdeduplication: here.
There must be 3 types of tagsevents set in order to track additional events:
"FB Pixelintegration" tagintegration firing on all pages is just the initialisation script that you will get from Facebook."MEInit"Inittagis the SDK initialisation script that you can find in our docshere.."UUIDdependency"dependency tag imports library for creating event id, but something different can also be used, e.g. unique form id + timestamp when a user sent it.
Warning: Those 3 tags must be in place in order to set other tags for particular events. On top of it achEach event must have a unique tag. E.g. if you set multiple forms submitted, each must have its own tag set.
Remember: For "currency" and "value" parameters, it is required to specify a value for it.
Refer here for more details.
Below is an example of settingsthe setting for the form submit
type of event.
"Events - Form submit - Newsletter" is triggered by newsletter form submission and is set up in the following way:
<script>
var uuid = uuidv4();
var email = $(".sib_signup_form input[name=email]").val();
var firstName = $(".sib_signup_form input[name=FIRSTNAME]").val();
var lastName = $(".sib_signup_form input[name=LASTNAME]").val();
var country = $(".sib_signup_form input[name=COUNTRY]").val();
if (typeof MeiroEvents === "object")
{
MeiroEvents.track("contactFormSubmit", {
form_id: "nl_signup_form",
email: email,
first_name: firstName,
last_name: lastName,
field00: uuid,
field01: country,
field02: "formSubmit" //note that the name matches exactly with the fbq event
});
}
if (typeof fbq === "function") {
fbq('track', 'formSubmit', {}, {eventID: uuid});
}
</script>
When the tag is triggered, it creates uuid
(defined in the code above field00: uuid
and {eventID: uuid}
), extracts user filled data from form inputs and then sends both Meiro Events and Facebook events with the created uuid
.
How to test if it works
Check Facebook Pixel helper (extension to Chrome) where events are sent to Facebook Pixel. Then, check the event id and you can compare it to the Meiro Events tracking calls from the network tab if it matches (browser console).
If it matches, the implementation went well.