Summary
Firing MadSpend events such as Qualified Conversion
and Purchase
through Google Tag Manager can:
- Tell Facebook what leads would convert, which trains the Facebook AI with the predicted lead values (see MadSpend use case), and
- Help track your Facebook leads through the entire funnel.
The summary of steps include:
(1) Ensure you have a data layer variable set up
(2) Set up a trigger
(3) Set up the Custom HTML tag firing the event
Note that Steps 1 and 2 are optional only if you don't already have a form submission capture already set up within Google Tag Manager. If you already have it, please feel free to use them and ignore Steps 1 and 2.
Setup steps
- Ensure you have a data layer variable set up
- Navigate to the Variables tab
- Create a new Variable
- Ensure the new Variable is based on the Data Layer Variable
- Select event as the Data Layer Variable name
- Set up a trigger
- Navigate to the Triggers tab
- Create a new Trigger
- Ensure the new Trigger is configured as a Custom Event
- Select the event name when your forms are being clicked on or submitted
- Set up the Custom HTML tag firing the event
- Navigate to the Tags tab
- Create a new Tag
- Ensure the new Tag is configured as a Custom HTML tag
- Enter the following script below into the Custom HTML field
- Ensure you select the trigger you created in Step #2
The script is as follows:
<script>
// this is dependent on how you pass your email input field
var email = form.track_input($('input[type=email]'));
madkudu.identify({ email: email })
madkudu.track('qualify', { email })
madkudu.user().qualify((err, results) => {
if (err) {
return;
}
var user = madkudu.user()
var is_qualified = user.is_qualified()
madkudu.track('qualify_results', { customer_fit_segment: user.customer_fit_segment(), qualified: is_qualified })
// send the predicted value back to facebook as a conversion
if (mk_predicted_value) {
fbq('track', 'Purchase', { currency: "USD", value: mk_predicted_value });
console.log('FB - Event Fired - ', mk_predicted_value);
};
</script>