Blog / crm
How to Set Up Conversion Tracking for HubSpot Forms Using Google Tag Manager (Updated for the New HubSpot Form Editor)
Setting up conversion tracking can be a headache — finding the right trigger that fires only when it should often feels like searching for a needle in a haystack. But without accurate tracking, you'll never get a clear picture of how your marketing campaigns are actually performing.
Setting up conversion tracking can be a headache: finding the right trigger that fires only when it should often feels like searching for a needle in a haystack. But without accurate tracking, you'll never get a clear picture of how your marketing campaigns are actually performing.
Why This Matters
One of the most crucial conversion points — especially when running lead generation campaigns — is form submissions. If your forms aren't being tracked properly, you're flying blind on lead quality and campaign ROI.
The Challenge with HubSpot's New Form Editor
HubSpot's new form editor changed how forms render and submit. Legacy GTM triggers that relied on hs-form-submitted may no longer fire correctly. Here's the updated approach.
Step-by-Step Setup
1. Enable Enhanced Measurement (if using GA4)
In your GA4 property, enable Enhanced Measurement and enable form interactions. This captures some form submissions automatically, but won't distinguish between different forms.
2. Create a Custom Event in GTM
In Google Tag Manager, create a new trigger:
- Trigger Type: Custom Event
- Event Name:
hsFormCallback - Fire on: All Custom Events
3. Configure the HubSpot Form Callback
In your HubSpot embed code, or via GTM's Custom HTML tag, add:
window.addEventListener('message', function(event) {
if (event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmitted') {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'hsFormCallback',
formId: event.data.id
});
}
});
4. Create Your GA4 Event Tag
- Tag Type: Google Analytics: GA4 Event
- Configuration Tag: Your GA4 Config tag
- Event Name:
generate_lead(or your preferred conversion event) - Trigger: The custom event trigger from Step 2
5. Test Before Publishing
Use GTM Preview mode to confirm the trigger fires on form submission — not on page load or other events.