Google Tag Manager

Track Hubspot Forms with Google Tag Manager

Questions about this article?

Open it in your AI assistant to summarise it or apply it to your setup.

Hubspot forms

Forms created with Hubspot are difficult to track with Google Tag Manager’s native triggers.

I’ll show you how to track only valid submissions of a Hubspot form, and also how to get user data (such as email address) to send to advertising platforms.

Video Watch the video tutorial Subscribe to the channel

This video is blocked

You haven't accepted YouTube cookies. Allow them to watch the video.

Install Hubspot Form listener

To listen for valid Hubspot form submissions, you need to fill in the form below to get the full code of the Hubspot Form Listener to add to Google Tag Manager with a custom HTML tag.

1if(typeof HubspotFormsV4 != 'undefined') {
2  window.addEventListener("hs-form-event:on-submission:success", function(event) {
3// Fill in the form below to access full working code

Get the full Hubspot Form Listener code by email

Your address is only used to send you this resource. Privacy policy.

Custom HTML tag to add the Hubspot form listener
Custom HTML tag to add the Hubspot form listener

I recommend to trigger this tag only on the page(s) that contain Hubspot forms.

Example of a valid form submission

On a valid form submission, the generate_lead event is sent to the Data Layer.

If you have several forms on the same page, you’ll need to use the form_id variable to differentiate them in GTM.

Generate_lead event in Data Layer
Generate_lead event in Data Layer

Create the corresponding Data Layer variables

Form identifier

Retrieve the form_id in the Data Layer
Retrieve the form_id in the Data Layer

Form fields

Here you need to create a variable for each field of your form.

Recover form fields in the Data Layer
Recover form fields in the Data Layer

Going further

You can send the user data collected via your Hubspot form to advertising platforms to improve your performance:

Comments

Join the discussion

A question, some feedback, a specific case? Leave a comment: I reply to every one.

Let's talk about your tracking

A question about this article, need an audit of your setup or server-side migration? Drop me a line, I reply within 24h.

Prefer to talk it through? Book a discovery call →