Capture conversions from HubSpot forms in Google Analytics GA4 (with GoogleTagManager)

by Meike Müller

Here you can find instructions to capture conversions from HubSpot forms in Google Analytics GA4 using GoogleTagManager ( if necessary also with ServerSideTracking). We run into a common problem here:

HubSpot forms are loaded in an iFrame and GoogleTagManager cannot automatically capture form submissions at this level. How we can work around this and still capture all form submissions, we will show you in five steps in the following tutorial.

Reading time 5 min

1. create data layer variables

This step happens in the GoogleTagManager (not the ServerSideManager if you are using ServerSideTracking).

First, we need to be able to access three data layer variables. To do this, we create them under the variables:

Google Tag Manager Integrierte Variablen

This step is not mandatory, but in our case we still want to pass the eventCategory, eventAction and eventLabel parameters to our GA4 property as well, just like in UA Analytics.


2. create trigger

Now we define a trigger that responds to the event name hubspot_form_submission and otherwise fires all results with that name.

Google Tag Manager Trigger erstellen


3. create tag and assign trigger

As a final configuration step, we create a tag of tag type "GoogleAnalytics: GA4 event". This tag will then forward the event accordingly towards GA4 or ServerSideTracking container, depending on the configuration:

Google Tag Manager Tag-Konfiguration


4. triggering an event after submitting a HubSpot form.

<script data-hubspot-rendered="true">
region: "eu1",
portalId: "1337",
formId: "xyz-123",
onFormSubmit: function($form) {
'event': 'hubspot_form_submission',
'eventCategory': 'forms',
'eventAction': 'submit',
'eventLabel': window.location.pathname});

HubSpot provides a function called onFormSubmit as part of its JavaScript Embedd API, which is triggered after the form is submitted. Here we hook in to set a few DataLayerVariables, which we then intercept in TagManager and pass on to GA4.

The DataLayerVariables 'eventCategory': 'forms', 'eventAction': 'submit' and 'eventLabel': window.location.pathname are not absolutely necessary, but facilitate a further filtering of the submissions within GA4.


5. mark events as conversion in GA4

In order to see the events that are now forwarded to GA4 as conversions, you have to create them as such under Configure -> Conversions. You do this via the button "New Conversion Event". Enter "hubspot_form_submission" as the event name.

Google Analytics 4 Events als Conversion markierenDone: With these steps, you should be able to track embedded HubSpot forms as conversions within your GA4 property without many problems.



FAQ around the topic of HubSpot Conversion Tracking

To conclude this article, we'll address a few questions that come up frequently in connection with conversion tracking. If you still have questions, we at EXWE will be happy to answer them by phone.


What is a conversion anyway?

A conversion is a term used to describe when a person performs a desired action on a website or app, such as making a purchase or filling out a form. This term is often used in the context of marketing, where the goal is to get people to perform a specific action on a website or app. In this context, a conversion is a way to measure the effectiveness of a marketing campaign or website design in terms of how well it is able to get people to take a desired action.


Google Universal Analytics VS GA4

Google Analytics is a web analytics service offered by Google that tracks and reports on website traffic. There are two versions of Google Analytics: Universal Analytics and the newer and from mid-2023 exclusively supported.

Universal Analytics is the older version of Google Analytics and uses a JavaScript snippet to track website visitors and collect data. This data is then used to create reports that help website owners understand how their visitors interact with their website.

GA4 is the newer version of Google Analytics. GA4 can also be implemented classically via a JS snippet or incorporated through GoogleTagManager, for example. GA4 uses machine learning to automatically identify important trends and insights in your website data and offers advanced tracking and reporting features compared to Universal Analytics.

One of the main differences between Universal Analytics and GA4 is that GA4 is designed to be more user-friendly and intuitive, with a focus on automated insights and predictive analytics. It also offers stronger integration with other Google products and services, such as Google Ads and Google Cloud. Universal Analytics is currently still widely used, but as of mid-2023, no new tracking data will flow into this expiring environment.


What is HubSpot?

HubSpot is a customer relationship management (CRM) platform that provides a suite of tools for managing customer interactions, including marketing, sales, and customer service. It is designed to help businesses grow by attracting, engaging and delighting customers. HubSpot offers a range of products, including free and paid options, to meet the needs of different businesses. Key features of the platform include email marketing, live chat, marketing automation and sales tracking.


Was ist dein Projekt? Wenn du uns darüber erzählen möchtest, rufen wir dich zurück!

from 07.11.2022

Hello, my name is Meike. I take care of the EXWE back office and am responsible for our social media channels. All of our articles are meant to make your life easier and help you make decisions. Nevertheless, it can happen that something remains unclear, so: If you have questions about this article you can easily reach me at +49 231 93149827.

Du möchtest immer am Zenit der Technik bleiben? Keine News und Blogbeiträge mehr verpassen.
We also have the following interesting posts from our tech blog for you on this topic
Successfully create and optimize SEA and PPC accounts

The ultimate step-by-step guide for online shops. Optimize your GoogleAds account and use Search Engine Advertising for your business.

Why your online store will benefit from SEA

And why search engine advertising is so important in e-commerce and for your store - Professional SEA management for your successful e-commerce.