Weblog | The online journal

HubSpot Form Tracking with GTM & GA4: Guide & Expert Tips

Written by Markestac | February

Introduction

Have you ever wondered why you keep getting emails from a website you visited several months ago? Or why a business keeps sending you newsletters even though you have never purchased anything from them? Both these questions have the same answer: Online form submission. 

Online forms have revolutionized online businesses, as they can now collect the necessary information, store it in their database, and nurture their target audience. 

If you own a business online in today’s day and age, you must utilize this feature and enhance your business performance. While some businesses misuse the information and start spamming their audience, you can use it strategically and provide your customers with a personalized experience. 

Putting HubSpot forms in highlight, we will learn all about HubSpot form tracking in GA4. So, let’s get started.

What are HubSpot forms?

HubSpot Forms is an online tool that helps businesses capture leads and collect data from website visitors. These forms help you gather the information and store it in your database, where you can track and analyze these submissions. 

HubSpot form tracking provides you with necessary insights about your audience, helping you make strategic decisions in favor of expanding your business & enhancing your marketing efforts. 

What is Google Tag Manager?

Google Tag Manager or GTM is a digital tool that allows users to easily manage and implement tags on their website without the involvement of a developer. 

You can track unique tags on your website and make data-driven decisions, all without prior coding knowledge. 

GTM is mostly used by businesses or websites to track website events such as clicks on CTAs, form submissions, etc. You can streamline your data collection, optimize paid ads, and gain valuable insights into user behavior by using HubSpot form tracking with GTM.

How HubSpot form tracking can benefit you?

There are several benefits of HubSpot form tracking in GTM. Here are a few of them:

Streamline data collection:

Streamline Data Collection Process

You can centralize and organize the data collection process by enabling HubSpot form submission tracking in Google Analytics. GTM works like a centralized hub where all kinds of tags, triggers, and variables can be managed seamlessly; making data collection simple.

Gain Insights Into User Behavior

HubSpot form tracking in GTM allows businesses to gain valuable insights into user behavior. Analyzing form submission data can reveal preferences, patterns, trends, etc. Additionally, you can customize your form fields in HubSpot to collect more focused data on specific topics.

Create Custom Audiences

You can create custom audiences based on the behavioral patterns and preferences you pick up through HubSpot form tracking. Creating custom groups also helps in audience segmentation. You can utilize this feature by directing emails or campaigns towards a specific target group.

Optimize Paid Ads

Businesses can identify which forms are most commonly submitted by users and how they interact with paid ads using the information collected through GTM. The retrieved insights enable them to make improvements to their paid ad campaigns. Understanding which forms perform better helps allocate the budget effectively.

Create Targeted Marketing Campaigns

HubSpot from tracking in GTM facilitates the segmentation of users based on their form submission patterns. You can leverage this segmentation to develop targeted marketing campaigns that serve specific user groups. Personalized marketing efforts have proven to be beneficial over and over again.

How to set up HubSpot from tracking in GTM

Prerequisite: What do you need?

To implement your modifications successfully, ensure you have edit permissions in Google Analytics and publishing privileges in Google Tag Manager. Additionally, make sure that you have HubSpot forms integrated into your website.

Prerequisites:

  • Google Analytics (Edit access)
  • Google Tag Manager (Publish access)
  • HubSpot Forms integrated into the website

Overview of the steps involved

  1. The entire process of setting up HubSpot from tracking in GTM  consists of four straightforward steps. Here they are:
  • Generate a custom HTML tag in GTM
  • Incorporate a dataLayer variable to read the GUID of the form
  • Create a trigger that reflects the success of the form submission
  • Integrate a Google Analytics Event Tag that reports the data to GA

Before you start: 

Please make sure Clicks and Forms ‘Variables’ in GMT are on. 

If you don’t know how to turn it on, follow these steps:

  • Go to variables in GTM

  • Under  ‘Built-in Variables’ > click ‘Configure’.

  • Check all the boxes under ‘clicks’ and ‘forms’ 

(I.e., click an element, click classes, click ID, form URL, Form text, etc.)

Integrate HubSpot form tracking in GA4

Step 1: Generate a custom HTML tag in Google Tag Manager 

The first step in enabling form tracking in GA4 is to create a custom HTML tag in Google Tag Manager. For that, you need to follow the steps mentioned below:

    • Go to the tag  section

    • Click New > Tag configuration > select Custom HTML

    • Copy & paste the following code into the HTML section

<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>

    • Next, set the trigger to fire on all the pages

    • Save

Step 2: Add a dataLayer variable to read the HubSpot form’s GUID

This step is also quite easy to perform. Follow these steps:

    • Go to variables

    • Navigate to user-defined variables

    • Click on Add new

    • Select data layered variable

    • Name it forms-hs-form=guid

    • Variable type: data layers variable

    • Variable name: hs-form-guide

    • Save

Step 3: Create a new trigger 

Creating the trigger for tracking forms in GTM takes nothing more than a few actions:

  • Add trigger type: Custom event

  • Add trigger name: Event-HubSpot-form-success

  • Add event name: HubSpot-form-success

  • Select action: Trigger fires on all custom events

Step 4: Create a Google Analytics Event Tag

Perform the following steps:

    • Create a new tag then select ‘Google Analytics: GA4 Event’

    • Name the tag: GA4_Event_Form_HS Success

    • Enter the GA4 measurement ID in the configuration tag field

    • Create a name for the event ie: Form_submit

    • Add event parameters (optional) 

    • Navigate to Triggering > Select the trigger we created: Event_hubspot_form_success 

    • Save

    • Submit all of your Google Tag Manager Updates (blue button at top right).

Step 5: Setup the new event as a goal in GA4

Once you are done configuring the tag and the trigger to enable form submission tracking in Google Analytics 4, you simply need to set up the conversion. To complete this process, perform the following actions:

    • Go to your GA4 property

    • Click on Under ‘admin’ > Click ‘Conversions’

    • Click ‘New conversion event’

    • Add your ‘Event Name’ (From step 4): Form_submit

    • Save

And that's all! You are done with the set-up.

Role of HubSpot professionals

Indeed, setting up tracking forms in GTM and GA4 does not need any advanced coding skills. However, hiring HubSpot professionals has its benefits. Here are some ways that HubSpot services can benefit you in yielding this process:

  • Saves time: Hiring a HubSpot professional saves you time and effort. They can take care of the implementation themselves and give you a complete product ready for tracking form in GTM.

  • Has experience: HubSpot service providers have plenty of experience in the field. Their expertise will ensure seamless deployment without any errors or obstructions. They can also help you with additional customizations. 

  • Team collaboration: By collaborating with your internal team, HubSpot professionals can help align all your form-tracking goals with broader marketing objectives. They might be able to help you refine your strategies based on the data you collect through form tracking in GA4.

Conclusion

Whether you hire HubSpot professionals or do it yourself, enabling HubSpot form tracking in GA4 is a major step toward the betterment of your business. Complete the process and watch as your marketing efforts yield results and conversions grow exponentially. 

Looking for HubSpot development services? Contact us!