Do you use HubSpot for marketing automation and Google Tag Manager (GTM) to integrate tools like Google Ads and Analytics? If yes, keep reading.
Here, we'll explain the steps to set up HubSpot and GTM so that your data tracking is both accurate and reliable, right from our internal documentation here at Revstac. When you're ready, automatically generate the code you'll need with the HubSpot Tag Builder.
Let's start with a brief overview of these tools:
- HubSpot is (among other things) a marketing automation platform. One of its core features is forms. This guide focuses forms — and how they talk to other tools.
- Google Tag Manager is a tag management system. It's basically the bridge between your website and digital marketing tools such as Google Ads, Analytics, and Instagram Ads. This guide focuses on collecting form data from HubSpot and passing it to these other tools by way of Google Tag Manager.
Step 1: Install the HubSpot tracking code
If you're already using HubSpot, you've probably already done this. The HubSpot tracking code is essential for sending website traffic data to HubSpot. You can install this code in various ways, including through Google Tag Manager. Follow the steps provided in this HubSpot support document for guidance.
Step 2: Track form submissions
First, set up a tag that "listens" for form submissions in GTM. This lonely chunk of code sits in the background of every page, waiting to jump into action when a user submits a HubSpot form.
Create a tag named “HubSpot Form Listener”. Set the Tag Type to Custom HTML and paste the following code:
Set the Firing Triggers to 'All Pages', the default option
![Screenshot of the "HubSpot Form Listener" tag](https://cdn.prod.website-files.com/6553c780c893896a3a7c186f/656d7d70181159eed02c35a0_Screenshot%202023-12-03%20at%2011.18.48%20PM.png)
Okay, great. Next, create a form submission trigger. When somebody submits a form, this trigger will fire. All your other tools that need to know about form submissions — like Google Ads and Meta Ads — will reference this trigger.
Add a trigger named “HubSpot Form Submission”. In Trigger Configuration, select Custom Event and set Event Name to hbsptFormSubmit. Set it to fire on all custom events.
![](https://cdn.prod.website-files.com/6553c780c893896a3a7c186f/656d7e10731f56c3cbd82a5e_Screenshot%202023-12-03%20at%2011.21.37%20PM.png)
Step 3: Passing form field data to other tools
In cases where specific form field data needs to be sent to GTM (e.g., a “Number of Employees” field influencing a Google Ads Conversion), follow these steps:
First, you'll need to update the code in your HubSpot Form Listener Tag (see step 2) with the fields you'd like to track. Add each field's internal name in HubSpot. In this case, we've added numemployees, the internal name for our “Number of Employees” field.
![](https://cdn.prod.website-files.com/6553c780c893896a3a7c186f/65775473ac8e194a8dd18136_Screenshot%202023-12-11%20at%2010.22.18%20AM.png)
No need to fret about getting this code exactly right. We built a free tool to generate it for you.
Next, you'll create a new variable for each field.
To do this, add a new User-Defined Variable, like “Number of Employees”. Set Variable Configuration to Data Layer Variable and link it to the corresponding internal property name in HubSpot.
![](https://cdn.prod.website-files.com/6553c780c893896a3a7c186f/656d7e61b149e5acd86ff84b_Screenshot%202023-12-03%20at%2011.22.57%20PM.png)
Now, this variable can used in Tags and Triggers. For instance, you can create a trigger for form submissions where “Number of Employees” is over a certain threshold, and link this to a Google Ads Conversion tag.
These steps form the basic framework for integrating HubSpot with GTM, enabling consistent tracking across various marketing tools.