Advanced Guide: Tracking HubSpot Form Submissions in GA4 with Google Tag Manager
Margub Alam
GA4 & Web Analytics Specialist | Google Tag Manager | Digital Analytics Consultant | Web Analyst | Mixpanel? - Product Analytic | Amplitude Analytics| CRO | Advanced Pixel Implementation
Tracking form submissions is crucial for understanding user interactions and conversions on your website. If you're using HubSpot forms, you can set up tracking in Google Analytics 4 (GA4) via Google Tag Manager (GTM). This article walks you through an advanced step-by-step guide to implementing this tracking setup.
Step 1: Identify the Form Submission Event
HubSpot forms don't trigger traditional form submission events like native HTML forms. Instead, they rely on JavaScript-based events. Here's how to capture these:
Step 2: Create a Custom Trigger in GTM
If no built-in GTM trigger is fired, you'll need to set up a custom trigger. HubSpot offers a onFormSubmit callback in its forms API, which you can use.
<script>
hbspt.forms.create({
portalId: 'YOUR_PORTAL_ID',
formId: 'YOUR_FORM_ID',
onFormSubmit: function() {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'hubspotFormSubmit',
formId: 'YOUR_FORM_ID',
});
}
});
</script>
2. Verify Trigger Execution:
Step 3: Set Up a GA4 Event Tag
Now that you have a hubspotFormSubmit event in the Data Layer, configure GA4 to capture it.
2. Add Event Parameters:
3. Set Trigger:
Trigger Type: "Custom Event Trigger."
4. Test the Tag:
Step 4: Verify in GA4
领英推荐
2. Custom Event Configuration:
Optional: Enhance Tracking with Event Attributes
Add custom dimensions or metrics to capture more details about the submission, such as:
Troubleshooting Tips
2. No Data in GA4:
3. Debugging Data Layer Push:
Conclusion
With the above setup, you'll be able to track HubSpot form submissions in GA4, enabling a comprehensive view of user interactions. This data helps optimize your forms, improve conversion rates, and make informed business decisions. If you have any issues or questions, feel free to leave a comment or reach out!
I’m passionate about empowering organizations with data-driven decision-making while respecting user privacy.
Here’s how you can connect with me or view my work:
Upwork Profile: Upwor
Freelancer Profile: Freelancer
My Blog on GTM & Website Analytics: Google Tag Manager Solution
If you or someone in your network is looking for an experienced professional in this space, I’d love to connect and chat further!