APIs & Integrations

VictorEekhof
Member

Hubspot tracker integration on SPA with GTM

Hi there,

 

First post here. I'm trying to integrate the general Hubspot tracker code with our Single Page Application (using BarbaJs, HTML5 push-state). Normally I can make it work with the "History State" trigger, but when I use this for Hubspot it doesn't pick up any form submissions.

 

This works, the form submission gets picked up by Hubspot: 

- Refresh on the contact page, submit form

 

This doesn't work:

- Refresh on the homepage, go to the contact page, submit form

 

Any ideas?

0 Upvotes
3 Replies 3
VictorEekhof
Member

Hubspot tracker integration on SPA with GTM

Thanks @dennisedson and @Mike_Eastwood!
I did check out this documentation, yes, but what isn't clear to me is what exactly I need to fire to allow the forms to be tracked. On non-SPA applications this seems to be done automatically, and as far as I know only the trackPageView call is fired. So do I simply need to manually call trackPageView on every other page apart from the one the user lands on?

0 Upvotes
Mike_Eastwood
Key Advisor | Gold Partner
Key Advisor | Gold Partner

Hubspot tracker integration on SPA with GTM

Hi @VictorEekhof 

 

If you're happy with JavaScript you can create your own tracking events.

 

https://developers.hubspot.com/docs/api/events/tracking-code

 

Have fun

Mike

dennisedson
HubSpot Product Team
HubSpot Product Team

Hubspot tracker integration on SPA with GTM

@VictorEekhof , did you happen to see the documentation on Single page application + HubSpot tracking code

You will have to scroll down a bit for SPA specific information.

@Mike_Eastwood 👋, any additional thoughts on this one?

0 Upvotes