For tracking any submissions from your embedded Hubspot forms on your external website (not on Hubspot pages) you will want to add the following within your Google Tag Manager.

  1. Go to Tags and create a new Google Analytics: GA4 Event tag.
  2. Attach your existing GA4 Configuration Tag or paste in your GA4 Measurement ID
  3. Set the Event Name to hubspot_form_success
  4. Click on Triggering to add a new trigger and select Custom Event
  5. Set the custom events name to hubspot-form-success and to fire on All Custom Events
  6. Save this tag
  1. Go to Variables and add a new Data Layer Variable
  2. Set its name to hs-form-guid and use Data Layer Version 2

For actually trigger these events, go back to Tags and create a new Custom HTML tag and add the following.

<script type="text/javascript">
  window.addEventListener("message", function(event) {
    if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmitted') {
      window.dataLayer.push({
        'event': 'hubspot-form-success',
        'hs-form-guid': event.data.id
      });
    }
  });
</script>

Save and publish your new tags and your should start seeing your HubSpot events tracking in Google Analytics 4.

Share Article

Related Articles

Tools + Resources

Freelance Hourly Rate Calculator

Social Media Image Sizes

Still haven’t found what you’re looking for?

Let us know and we’ll do our best to help out!

sit back and relax

We have monthly site maintenance options to ensure that your website is running smoothly.

Website development post-launch support and resources