HubSpot Tracking Code Scraping Squarespace Forms Incorrectly

Status: Idea Submitted

Use Case

We have a basic Squarespace form on our website to collect emails for a Newsletter subscription. Logically this should appear as a single form in HubSpot but it is getting created as a new form for every single submission due to a bug in how HubSpot developed the code to uniquely identify forms. This is creating an administrative nightmare and it is not effective in classifying data in HubSpot. We lose the ability to leverage conversion analytics and understanding when contacts arrive from our public website newsletter because every contact created appears to be ceated from a differnet unique form. This is a bug in the HubSpot tracking code and should be corrected. Any workarounds would be appreciated in the meantime. I am trying to think of a way to inject my own javascript to replace ID values in the Squarespace forms ahead of the HubSpot javascript so I can force the proper standardized form identifiers.

Detailed Technical Analysis

Grab the collectedforms.js from embedded in HubSpot’s main tracker code:

After beautifying the javascript, line 3679 shows where HubSpot specifically caters to squarespace.com domains. You can also search for “squarespace” to find the Squarespace-specific block of code. This block describes how the form ID is built to be ingested by the tracking code. It is interesting to see that HubSpot specifically developed the tracking code to support Squarespace websites.

The general problem with the collectedforms.js script is that the Squarespace “yui” selector is used and it should not be. Instead the “collectionId” or “formId” identifiers should be used to uniquely identify a form to scrape and pass into the “formGuid” field in the HubSpot Form submission API. I would then use the form class name to provide a pretty name back to HubSpot so contacts have something meaningful added versus a randomly generated number, which inflates the Hubspot marketing forms tremendously. Maybe the form class could pass into the “pageName” field or “pageUri” when the tracker script pushes back to HubSpot.

I am not an expert in javascript, but I would be open to trying to figure out how to overwrite values on the page to correct the problem on the fly so HubSpot’s collectedforms.js script does not see the randomly generated “yui” values.

Any ideas?

Reference on Squarespace “yui” selectors:

As an example of the administrative problems created, deleting a redundant form created by every single form submission creates a problem when clicking the link into that respective form from the contact timeline. Viewing the deleted form just opens a window with an endless spinning circle.

Did you find a solution or workaround? Still appears to be an issue