Are you using Formidable Forms on your WordPress website to generate leads? Tracking successful form submissions in Google Ads helps you understand which campaigns bring valuable leads.
In this guide, I’ll show you how to track Formidable Forms using Google Tag Manager (GTM) and configure Google Ads Enhanced Conversions to improve conversion measurement.
How to Track Formidable Forms for Google Ads Enhanced Conversions ? Check This Video
Why Are Google Ads Enhanced Conversions Important?
Standard conversion tracking helps Google Ads record when someone completes a form. Enhanced Conversions can improve conversion matching by securely using eligible first-party customer data, such as email addresses, when available and permitted.
This can help you measure lead-generation performance more accurately and give Google Ads better conversion signals for campaign optimization.
Formidable Forms Tracking Code
To track form submissions reliably, you need to identify when the form has been successfully submitted and make the relevant form data available to GTM.
<script>
(function() {
var origXMLHttpRequest = XMLHttpRequest;
function pushFormidableEvent(formIdentifier, requestBody) {
var cleanedRequestBody = mapFormFields(requestBody);
if (isFormValid(cleanedRequestBody)) {
cleanedRequestBody.form_id = formIdentifier || 'default_form';
var eventToFire = 'formidable_form_fired';
if (!dataLayerContainsEvent(eventToFire)) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: eventToFire,
inputs: cleanedRequestBody
});
}
}
}
XMLHttpRequest = function() {
var xhr = new origXMLHttpRequest();
var origOpen = xhr.open;
var origSend = xhr.send;
var requestUrl = '';
xhr.open = function(method, url) {
requestUrl = url;
return origOpen.apply(this, arguments);
};
xhr.send = function(data) {
if (data instanceof FormData && requestUrl.includes('admin-ajax.php')) {
var requestBody = {};
data.forEach(function(value, key) {
requestBody[key] = value;
});
pushFormidableEvent(requestBody['form_key'], requestBody);
}
return origSend.apply(this, arguments);
};
return xhr;
};
function mapFormFields(inputs) {
return {
first_name: inputs['item_meta[17]'] || '',
last_name: inputs['item_meta[18]'] || '',
email: inputs['item_meta[3]'] || '',
phone: inputs['item_meta[16]'] || '',
message: inputs['item_meta[5]'] || ''
};
}
function isFormValid(inputs) {
return inputs.first_name && inputs.email && inputs.phone;
}
function dataLayerContainsEvent(eventName) {
return (window.dataLayer || []).some(entry => entry.event === eventName);
}
document.addEventListener('submit', function(event) {
var form = event.target.closest('form');
if (form && form.getAttribute('id') === 'form_contact-form') {
var formData = new FormData(form);
var requestBody = {};
formData.forEach(function(value, key) {
requestBody[key] = value;
});
pushFormidableEvent(formData.get('form_key'), requestBody);
}
}, true);
})();
</script>
Change Form Class or ID or Use ChatGPT to change form Id or Class
How to setup in the Google Tag manager?
- 1st. In the Google Tag Manager make a custom HTML Tag where you need to add above Formidable Tracking Code then Select All Pages Trigger
- 2nd. Complete the Custom HTML Tag Setup go to preview then submit the form and then click Data Layer where you will get Form submit event and User Data like Email and Phone with other details
- 3rd. In the Google Tag Manager Go to the Variables then click Add new variable and select Data Layer Variable after that add Tag Assistant Preview Data Layer User Data like Email and Phone
- 4th. In the Google Tag Manager Go to Trigger then New Trigger and select Custom Trigger and add Tag Assistant Preview Data Layer Event name
- 5th. Complete the Custom HTML Tag, Trigger, and Variable setup Google Ads Enhanced Conversion Tracking
Test Your Form Tracking
Submit a test entry and verify that the conversion tag fires at the correct time. Check that the correct conversion action is used and that customer data is mapped properly.
Accurate Formidable Forms tracking helps you understand which Google Ads campaigns generate leads. With Google Tag Manager and Enhanced Conversions configured correctly, you can improve conversion measurement and make better-informed campaign decisions.
Need help setting up Google Ads conversion tracking or Enhanced Conversions?
Work with me: https://adsmetricx.com/contact/
If you’d like to work with me on Fiverr, check out my profile here: View My Fiverr Profile