ePrivacy and GPDR Cookie Consent by Cookie Consent Skip to main content

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 in the 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 data analysts can sync the basics of this function.

Warning: each event needs to have a unique event id. 

 

<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>