Form Tracking for HubSpot Forms

HubSpot forms are an extremely popular way to capture leads and pass data into your CRM. There are two potential ways to add Zuko tracking to your HubSpot form depending on your setup:

a) The HubSpot form is fully integrated into your site.

At higher pricing package levels, you are able to add HubSpot forms directly to your site as part of the build. If this is the case, you can install Zuko like you would for any other form. Simply add the two code tags on form load and form completion and Zuko will pull in all the form tracking data automatically.

b) The HubSpot form is iFramed in

More commonly, your HubSpot form may have been embedded by pasting a piece of code generated by HubSpot.

In this case, the form will be iFramed into your site and you won't have direct access to add Zuko code tags.

To track an iFramed form, locate the tag where you are currently showing your HubSpot form. It will look something like this:

<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/embed/v2.js"></script>

<script>

 hbspt.forms.create({

   region: "na1",

   portalId: "YOUR_HUBSPOT_PORTAL_ID",

   formId: "YOUR_HUBSPOT_FORM_ID",

 });

</script>

Then, locate your Zuko form ID. This can be found on the settings page of the form in the Zuko app in the "Edit Form" section:

Replace the HubSpot tag above with the following:

<script src="https://assets.zuko.io/js/v2/client.min.js"></script>

<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/embed/v2.js"></script>

<script>

 const zukoFormId = "YOUR_ZUKO_FORM_ID";

 const slug = zukoFormId;

 hbspt.forms.create({

   region: "na1",

   portalId: "YOUR_HUBSPOT_PORTAL_ID",

   formId: "YOUR_HUBSPOT_FORM_ID",

   onFormReady: ({ 0: $form }) => {

     Zuko

       .trackForm({ slug })

       .trackEvent(Zuko.FORM_VIEW_EVENT);

     for (const eventType of Zuko.eventTypes) {

       $form.addEventListener(eventType, ({ type: eventType, target: { tagName, type, name } }) => {

         const element = document.createElement(tagName);

         element.name = name;

         try {

           element.type = type;

         } catch (_) {

           // Ignore

         }

         Zuko

           .trackForm({ slug })

           .trackEvent({ type: eventType, target: element });

       })

     }

   },

   onFormSubmit: () => Zuko

     .trackForm({ slug })

     .trackEvent(Zuko.COMPLETION_EVENT),

 });

</script>

Remember to replace the following placeholders with the correct values for your HubSpot form and the corresponding form in Zuko:

Zuko events should then be firing on your HubSpot form and be pushing into the Zuko dashboards.

See more guides
zuko full colour logo
Formisimo Ltd, Colony, 5 Piccadilly Place, Manchester, M1 3BR
VAT Number: GB181252425
Registered in England as company number 08859680
New Business: sales@zuko.io
Support: support@zuko.io