How to collect data from a hidden field in a Non-HubSpot Forms
We had an interesting challenge this week - using hidden fields in a non-HubSpot Form. Usually we embed HubSpot forms in websites to make it easy to control. But in this case the website was all custom bespoke code with forms on hundreds of pages.
We wanted the hidden field to populate a Custom Property in the Contact Record to trigger a Workflow. The data in the field is dynamically generated so it wasn't practical to create custom forms for each page.
If you add a hidden field to a non-HubSpot Form then HubSpot will ignore it when parsing the form data.
So, what we did was add a normal Text Input Field - with a dynamically populated default value - then hid the field with CSS (display: none).
HubSpot then parses the data in the field and updates the contact property. The visitor doesn't see another potentially confusing field and we only had to make one code change.
How to collect data from a hidden field in a Non-HubSpot Forms
I had the exact same need, ran into the same issue, and tried the same "trick", but it didn't work. If I style the text input with display:none, HubSpot ignores it.
How to collect data from a hidden field in a Non-HubSpot Forms
Note. Using CSS to hide the input fails, but wrapping it in a div and setting the div's "display:none" works. The user does not see the field, but HubSpot uses it.