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.

How To Send Funnel and CRM Purchases to a Facebook Pixel

Open Facebook Event Manager. If you don’t have a Pixel set up or would like to create new to keep track of purchases, click Add New Data Source – Facebook pixel and follow steps on screen.

Open Pixel Settings and make sure ‘Track events automatically without code’ is disabled. This is required to prevent duplicate events from being sent to Pixel from browser and server-side integration.

Press ‘Create Access Token’ button on the same page. Select a pixel you’d like to use and follow steps to create a new app. Choose to create an app in Development mode instead of Live. This is required to obtain access to Facebook Marketing API instantly.

Select or create a system user on the next step. A system user is a special Facebook user that will ‘own’ the access token, which allows not to renew the token regularly, as would be required by an integration that uses real user.

Open Facebook Business Settings for the Facebook Business that has access to the Pixel.

In Users – System Users select the System User that was created and press Add Assets to add an Ad Account that has access to the pixel with ‘Manage Ad account’ permission and an App that was created for the purpose of integration with ‘Develop app’ permission.

Once done, press ‘Generate New Token’ button, select the app and choose ads_management from the list of available permissions.

Press ‘Generate Token’ and save displayed token.

In Formsable

To begin sending Purchase events, Formsable will need to be configured with the new system user token.

Open ‘API Credentials’ and press ‘New Credential’. Select ‘Facebook’ service, enter access token that was created in the previous step. Refresh token can be left empty. Enter any name you can use to reference this token, such as name of the Facebook Business that it belongs to, in the ‘Name’ field. Press ‘Save’.

Open ‘Outbound’, press ‘New’ and select the Credential you’ve created in the previous step.

Choose desired Event Type (for example, ‘Purchase’), select Account and Adspixel from the drop-down lists below.

Press ‘Save’ once done.

All new events of selected type will now be sent to Facebook Pixel.