Web Analytics
How to Track HubSpot Form Submissions and Set Up Enhanced Conversions with GTM
Written by
Alana Rossi
Published on
March 11, 2025

How to Track HubSpot Form Submissions and Set Up Enhanced Conversions with GTM



HubSpot (HS) forms are a powerful tool for capturing leads and engaging visitors. However, tracking form submissions accurately is crucial for measuring performance, optimizing conversions, and understanding user behavior.

By leveraging Google Tag Manager (GTM), you can track form submissions seamlessly and send event data directly to Google Analytics 4 (GA4) for in-depth analysis.

In this guide, we’ll walk you through the step-by-step process of implementing enhanced conversion tracking for HubSpot forms using GTM, ensuring no conversion goes untracked.

Why Use Google Tag Manager to Track HubSpot Form Submissions?

While there are multiple ways to track HubSpot form submissions, using Google Tag Manager (GTM) offers unique advantages in flexibility, scalability, and control:

Centralized Tag Management

Manage all tracking scripts (GA4, Google Ads, Facebook Pixel, etc.) from a single interface without touching HubSpot or site code directly.

Custom Event Triggers for HubSpot

GTM lets you listen for HubSpot-specific events (like onFormSubmitted) and create custom triggers and tags based on form IDs, user data, or page context.

Scalable Across Multiple Forms

Whether you have 1 or 100 HubSpot forms, GTM allows consistent tracking setup without duplicating scripts across pages.

Enhanced Conversion Setup Made Easier

With GTM, you can easily push user data (like email and phone) into the Data Layer for Enhanced Conversions — no need to customize each individual HubSpot form.

Improved Debugging and Version Control

GTM’s Preview and Debug mode helps you test form tracking in real time, and version history gives you rollback safety.

By using GTM, you can track HubSpot form submissions more efficiently, with greater customization and less risk of breaking your site or forms.


Step 1: Capture HubSpot Form Submissions in the Data Layer

When a HubSpot form is successfully submitted, it triggers a built-in event called hsFormCallback. However, Google Tag Manager (GTM) doesn’t automatically detect this event — so we need to manually listen for it and push the relevant data into the Data Layer.

The script below listens for postMessage events from HubSpot forms. When it detects a form submission (onFormSubmitted), it extracts key information like the user’s email, phone number, and form ID (GUID), and then pushes a custom event called hubspot-form-success into the dataLayer. This makes the submission data available to GTM for tracking purposes, including Enhanced Conversions if set up properly.

Here’s the code you should place in your site’s <head> tag or inject via GTM:

<script type="text/javascript">
  window.addEventListener("message", function(event) {
    if (event.data.type === 'hsFormCallback') {
      var email = '';
      var phone = '';
      var formGuid = '';

      if (event.data) {
        formGuid = event.data.formGuid || event.data.id || '';

        if (event.data.data && event.data.data.submissionValues) {
          email = event.data.data.submissionValues.email || '';
          phone = event.data.data.submissionValues.phone || '';
        }
      }

      if (event.data.eventName === 'onFormSubmitted') {
        window.dataLayer.push({
          'event': 'hubspot-form-success',
          'hs-form-guid': formGuid,
          'email': email,
          'phone': phone
        });
      }
    }
  });
</script>

Step 2: Create a Custom Event Trigger in GTM

  1. Go to Triggers in GTM.
  2. Click NewTrigger Type: Custom Event.
  3. Set the Event Name to: hubspot-form-success.
  4. Set Trigger Fires On: All Custom Events.

Screenshot of the Hubspot custom event in GTM

Step 3: Fire Your Tags

Now, use this trigger to fire Google Analytics 4 (GA4) events.

        1. Create a new Tag in GTM.

        2. Choose Google Analytics: GA4 Event as the tag type.

        3. Connect the Measurement ID of your GA4 account.

        4. Set Event Name as hubspot-form-success.

An example of a GA4 tag for Hubspot events

        5. Set Event Name as hubspot-form-success.

Screenshot of a GA4 tag with user-provided data variable


        5.1 To configure the UPD Manually go to GTM > Variables > Choose ‘User-Provided Data’

Screenshot of a user-provided data variable

        5.2 Select Manual configuration and insert the variables for Email and/or Phone

An example of the user-provided data variable setup in manual in a GTM container

        6. Link it to the trigger created in Step 1.

Example of a Hubspot form submission trigger in GTM


        7. Test in Preview Mode and submit a test form. 


Example of a form


        7.1 Remember to check if the Google Tag Assistant is working correctly, this message should be showing on the screen 



Screenshot of Tag Assistant connected

        8. The event should appear on the left, and the tag should fire; To debug the user-provided data, check the API call, you must be able to see the client         information as set.



Final Thoughts

Accurately tracking HubSpot form submissions using Google Tag Manager (GTM) and Google Analytics 4 (GA4) is a crucial step toward understanding user behavior, optimizing conversion paths, and making smarter, data-driven marketing decisions.

By implementing the steps outlined in this guide, you’ll gain visibility into form interactions that might otherwise go unnoticed. This not only ensures that every lead is properly captured and attributed but also gives you the insights needed to fine-tune your campaigns, improve user experience, and ultimately increase your return on investment.

Whether you’re managing a few landing pages or running a large-scale demand generation strategy, having a reliable tracking setup is the foundation of effective digital marketing.

If you’re looking for hands-on support or want to ensure your GTM and HubSpot integration is set up correctly and efficiently, don’t hesitate to reach out. A solid tracking framework today can lead to smarter decisions and better results tomorrow.

Let's transform your data
strategy for real results

Unlock your potential with a data-driven strategy that fuels growth, boosts efficiency, and enhances decision-making. Our experts turn complex data into clear insights—let’s make it work for you. Book a call today!