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.

One of the most crucial conversion points, especially when working with B2B or lead generation companies, is tracking form submissions, for example, a Contact Us form, Request a Quote form, or a Newsletter sign-up form. There are many form builders out there and each of them require a different “trigger”. One common form builder is Hubspot Forms.

However, tracking HubSpot form submissions can be tricky, especially after HubSpot launched a new form editor/builder at the end of 2024. In this guide, we’ll walk you through updated, proven methods to track HubSpot form submissions reliably using Google Tag Manager (GTM) and HubSpot’s built-in tools.

Special thanks to Ayoola Idris-Animashaun for helping with this updated listener script!

Tracking conversions when using HubSpot’s new form builder

With the release of HubSpot’s new form builder we found out that our current tracking methods  were not working anymore. Previously, marketers could rely on a simple form listener script to detect form submissions in GTM. With HubSpot’s new form editor, that script stopped firing, leaving many marketers scratching their heads.

The good news? We have an updated form listener that works with all HubSpot forms!

In this guide, we’ll walk you through several effective, proven methods to track your conversions—compatible with Google Ads, LinkedIn Ads, Google Analytics 4 (GA4), Facebook Ads, and more. Plus, we’ll share a new script that works with both the legacy and new HubSpot form editors.

Method 1: Using HubSpot’s Built-in Events Tool (Easiest, but limited)

The easiest way to track HubSpot form submissions is by using HubSpot’s Ads Events tool. Here’s what you need to know:

Pros

Cons

We recommend only using this method if you are looking to set up conversions for the above 3 platforms. Not being able to set up the events for GA4 is a big miss, so this method is only recommended in certain circumstances.

How to set up conversion tracking in HubSpot to measure conversions in Google Ads, LinkedIn Ads, or Facebook Ads without coding

And that’s it! From this moment onwards HubSpot will start syncing over conversion events. Keep in mind that HubSpot only syncs conversions from the moment you set this up; it won’t backfill historical form submissions.

If you’re looking for the most reliable way to set up conversion tracking with HubSpot forms on your website, using Google Tag Manager is your best bet. We’ve used this script for many of our clients, and it has consistently proven to be the most dependable method. It’s easy to implement, especially once you get through the initial setup, and enhanced conversions work without any issues. While this method does require a bit more familiarity with GTM than simpler approaches, we’ll walk you through each step in a clear, easy-to-follow way. Even if you’ve never set up conversions in GTM before, you’ll be able to do it without any problems.

The challenge with HubSpot forms is that when you try to set up conversions using GTM’s preview mode, no useful data appears in the data layer. That’s where GTM listeners come in. By using a form listener, you can track events and changes in the data layer, which can then be used to set up reliable conversion points.

What do we need to do for this method?

    1. Add a custom variable (User-Defined Variable): This variable lets us pull specific data from the data layer, which helps with setting up precise form triggers. It gives us the flexibility to track and analyze form submissions more accurately.
    2. Add a custom HTML listener: This script listens for changes in the data layer and lets us detect when a form is submitted. Without it, we wouldn’t be able to track submissions reliably. The best part is that this script works with both legacy HubSpot forms and forms built using the new editor, so there’s no need to create different versions.
    3. Set up a form-specific trigger and tag: Use the HubSpot form ID to create a trigger that only fires when a specific form is submitted. This ensures you’re tracking only the submissions you care about, instead of every single HubSpot form on the site.

1. Add the User-defined variable

In this step, we’re going to add a new user-defined variable. Follow these simple steps:

2. Adding the HubSpot listener

Adding the HubSpot listener is the most important step because it allows us to track form submissions in Google Tag Manager. The script below works with all HubSpot forms, including those built with the legacy editor and the new form builder.


<script type="text/javascript">
    // Ensure dataLayer is available
    window.dataLayer = window.dataLayer || [];

    window.addEventListener("message", function (event) {
        if (!event.data) return;

        // For old legacy forms (v1)
        if (event.data.type === 'HS_CTA_FORM_SUBMITTED') {
            window.dataLayer.push({
                'event': 'hubspot-form-success',
                'hs-form-guid': event.data.id || event.data.formId
            });
        }

        // For recent legacy forms (v3)
        if (event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmit') {
            var formContainer = document.querySelector('.hs-form-frame');
            var formId = formContainer ? formContainer.getAttribute('data-form-id') : event.data.id;

            window.dataLayer.push({
                'event': 'hubspot-form-success',
                'hs-form-guid': formId,
              'event-data' : event.data
            });
        }
    });

    // For the latest forms (v4 API)
    if (document) {
        document.addEventListener('hs-form-event:on-submission:success', function (event) {
            var formContainer = document.querySelector('.hs-form-frame');
            var formId = formContainer ? formContainer.getAttribute('data-form-id') :
                (event.detail && event.detail.formId ? event.detail.formId : null);

            if (formId) {
                window.dataLayer.push({
                    'event': 'hubspot-form-success',
                    'hs-form-guid': formId,
                  'event-data' : event.data
                });
            }
        });
    }
</script> 

Once published, this listener will make form submissions visible in your GTM data layer so you can easily build your conversion tracking.

Let’s run a quick test:

    1. Run Preview mode in GTM
    2. Submit the form you’re trying to track.
    3. After submitting the form, head to the Summary page and see which events fired.
    4. If everything was implemented correctly, you see a new event with the name hubspot-form-success.

Are you seeing that? Then good news: your HubSpot form listener was implemented successfully! Next step: ensuring we set up conversions for individual forms!

3. Setting up your conversions (triggers) for specific form submissions

This last step allows us to set up conversions for specific forms. It doesn’t matter if you’re trying to set up conversions for a contact us, newsletter, request a quote, or gated content form. As long as it’s a HubSpot form we will be able to track it!

Finding your form ID

To set up the conversions for a specific form, we’re going to need a unique identifier. In the case of HubSpot forms, it’s going to be the “form ID”. There are 3 ways we can find the form ID:

    1. In the HTML/code of a page where the form has been implemented
    2. In the URL when viewing a form in HubSpot
    3. In Tag Manager’s Summary under Variables

Let’s take a look at all 3 methods:

    1. Finding the form ID in the HTML

The easiest way is to look in the page source of a page that contains the form you’re trying to track.

Alternatively we can also use Inspect (right click > Inspect) and search for formID in there. This method can sometimes be more reliable than looking in the page source.

    1. In HubSpot itself

This is probably the easiest method, but it does require you to have access to the HubSpot account. You can find the HubSpot form ID by:

    1. In Google Tag Manager’s Variables

This method requires you to submit the form in preview mode first, before you’re able to find the form ID.

4. Adding the trigger

Now that we have the form ID of the form we’re trying to track, the last step we need to take is setting up the trigger in Google Tag Manager. For that, we need to follow these easy steps:

Success!

We’ve now successfully set up the trigger for a specific form on your website. The final step is to connect this trigger to the correct tag so we can begin tracking conversions and events in your desired platforms (GA4, Google Ads, Microsoft Ads, Facebook Ads, etc).

Once the trigger is assigned to the tag, it’s time to do one final test. Run Google Tag Manager in Preview mode, submit the form you’re tracking, and check the Tag Assistant Summary to confirm that the tag fired. If it did, go ahead and publish your changes — and you’re all set!

To track additional forms, just repeat the process starting from Step 3. Be sure to create a unique trigger and tag for each form if you want to track them separately.