Trouble impementing embedded forms


Hello -


We're trying to get some Hubspot forms embedded on an external site. These forms have progressive fields but we're having some trouble getting them to work. We consistently see the "This form was submitted before the tracking code was installed. Some information may not have been captured as a result." despite the fact that the tracking code is being installed on the page via GTM.


I thought this was probably an issue with timing (form loading before tracking code was loaded) so I look around for an event that we could wait for before initializing the forms.


Seems that the tracking code sets up a `_hsq` array and two global variables `_hstc_loaded` and `_hstc_ran`. However, none of those side effects are present when the tracking code is loaded via GTM. Though if I include the tracking code in a `<script>` tag on the page I see those side effects.


Regarding the forms -- it seems that before being rendered they try to fetch analytics from the tracking code by pushing a request to the `_hsq` array. Our GTM implementation of the tracking code doesn't seem to be consuming items pushed to the `_hsq` array though. I noted this by observing that pushing a function that logs to the console to `_hsq` produces output when the tracking code is loaded via `<script>` tag but not when loaded via GTM.


So my questions are:


1 - Is it expected behavior that `_hsq`, `_hstc_loaded` , `_hstc_ran`, and the magic _hsq event listener aren't present in the client when the tracking code is loaded via GTM (or maybe we've done something wrong?)


2 - Is it possible for forms to get the necessary tracking data for progressive fields to work when the tracking code is loaded via GTM.


Thanks in advance for the help!


1 Reply 1
HubSpot Employee

Hey @dandrust,


It is certainly possible to install the HubSpot tracking code using Google Tag Manager and for this, we have a detailed documentation that I'd love to shared with you - Install the HubSpot tracking code (Under the 'Install the tracking code using Google Tag Manager' section). 


Could you run through the documentation and see if your team set up the implementation the same way? If it still doesn't work, it'd be helpful if you share with me the detailed steps by steps configuration that your team did to install the tracking code using GTM.