
GoHighLevel Form Event Listener
Track GoHighlevel form submission as conversion in your advertising platform, and analytics tools using Google Tag Manager, and the GoHighlevel form event listener (which makes it possible to fire your conversion tracking tags/pixels on successful GoHighlevel form submissions)
How to track GoHighlevel form submission with google tag manager
To track GoHighlevel form conversions with Google Tag Manager, all you’ll have to do is copy the event listener code and paste it into your custom HTML tag in GTM, trigger it on pageview.
<script>
(function() {
var inputData = {};
window.addEventListener('message', function (event) {
if(Object.prototype.toString.call(event.data) === '[object Array]') {
var inputJSON = event.data[2];
if(inputJSON && inputJSON.includes('full_address') && inputJSON.includes('customer_id') && inputJSON.includes('full_name') && inputJSON.includes('email')) {
var inputObject = JSON.parse(inputJSON);
inputData = inputObject
dataLayer.push({
event: 'ghl_form_submit',
inputs: inputObject
});
}
if(event.data[0] === 'msgsndr-booking-complete') {
dataLayer.push({
event: 'ghl_booking_complete',
inputs: inputData
});
}
}
});
})();
</script>
Next, you’ll have to navigate to triggers to create a custom event trigger type [ghl_form_submit] which will be used to fire your marketing tags/pixels such as Google Analytics, Google ads and Facebook Pixels etc.
Also, ensure your implementation is privacy compliant. Using trigger conditions in Google Tag Manager, you can streamline your conversion to be recorded on certain pages, form IDs or user types.
This event gets all the form field data captured in the form and can be used on the successful form submission event to enrich your data.
💡 Pro Tip: To access the data fields, create a datalayer variable.
Ⓒ Created This Code Md Hasanuzzaman