How to track HubSpot forms with Google Tag Manager?

When a HubSpot form has been successfully validated, HubSpot triggers an event that can be followed to activate Google Tag Manager tags. We'll see how to create a custom HTML tag that monitors these HubSpot form conversions and how to trigger a conv

HubSpot custom HTML form monitoring tag

Create a custom HTML tag, paste the code below into the tag's script and use "all pages" as the trigger.

Here is the custom HTML code to paste in the tag

<script type = "text/javascript">
window . addEventListener("message" , function( event ){
if( event . data . type === 'hsFormCallback'&& === 'onFormSubmitted'){
'event': 'hubspot-form-success',

The trigger “HubSpot form submitted successfully" 

You need to create a new trigger for the data layer event triggered by the event listener. This trigger is used to track successfully submitted HubSpot forms.

Tag linked to the conversion on a validated HubSpot form

Finally, create your tag corresponding to the conversion linked to the HubSpot form.

For Appvizer, this will be an HTML tag with the conversion script and as the trigger, the Custom Event above (HubSpot form success).