How To Attribute Conversions to Facebook Ads Click Ids

Attributing conversions to Facebook Ads is a common task, however doing it with sufficient precision is hard. Sales might happen in CRM, or, when they happen online, customer might not come back to the website, so tracking with Facebook Pixel JS produces substandard results.

Formsable resolves this by introducing concept of a Visitor. Visitor associates Events that happen on website, in CRM or offline by associating these Events using Visitor Keys. Visitor Keys are Visitor attributes that uniquely identify a customer across events and devices. The most common ones are email and phone.

In a typical integration scenario, fbclid parameter of initial hit is first associated with website-specific visitor identifier, the default being Google Analytics visitor id, and then, once a lead is submitted, associates a lead parameter such as e-mail with visitor id, and, by inference, with original fbclid.

All of this happens in Formsable engine automatically, provided PageView and Lead events are sent when respective actions occur.

Doing so requires adding following code on the website pages:

<script src="//app.formsable.com/uipe.js" async></script>
<script>
window.addEventListener('load', () => {
  uipe('init', "aaaaaaaaa-aaaa-aaaaa-aaaa-aaaaaaaaaaa") // Replace with funnel mark
  uipe('track', 'PageView')
  // attach event to your form and fields; following example is for Elementor Form plugin
  for (let form of document.getElementsByClassName('elementor-form')) {
    form.addEventListener('submit', (e) => {
      gtag('event', 'generate_lead')
      uipe('track', 'Lead', {
        keys: {
        email: form.elements['form_fields[email]'].value,
        phone: form.elements['form_fields[message]'].value,
      },
      lead: {
        firstName: form.elements['form_fields[name]'].value,
        lastName: form.elements['form_fields[field_4]'].value,
        company: form.elements['form_fields[field_1]'].value,
        country: form.elements['form_fields[field_2]'].value,
      }
      })
    })
  }
});
</script>

Once installed, you should be able to see Visitors with both fbclid and email keys in Formsable UI. The initial fbclid will also be used when sending configured Pixel events to Facebook Marketing API.