Capture HubSpot attribution in embedded and popup forms
Updated today
Embedded and popup forms can capture HubSpot visitor attribution automatically. Add a hidden field named exactly hutk to your form, and our embed script reads HubSpot's hubspotutk cookie from your page and passes the value into the submission β no custom JavaScript required.
Keep the three names straight: hubspotutk is the cookie HubSpot's tracking code sets on your page, hutk is the hidden field name inside your form, and Youform's Google Tag Manager integration is a separate paid feature for form events β it isn't needed for attribution.
Before you start
HubSpot's tracking code must be installed on the page where your form is embedded, either directly or through Google Tag Manager. Our script reads the cookie from the page regardless of how the tracking code was added, so Youform's Google Tag Manager integration is not required for attribution.
Attribution also depends on consent. The hubspotutk cookie is an analytics cookie controlled by HubSpot's consent banner, so visitors who withhold consent won't have it set and no attribution value is captured for them.
Attribution is handled by our embed scripts, so use the JS inline embed or the popup embed. The basic iframe embed doesn't include our script and can't capture the cookie automatically.
Add the hutk hidden field
The form must contain a hidden field named exactly hutk. There's no preset for it, so you enter it as a custom value in the hidden fields section of form settings.
Open your form from the dashboard.
Go to Settings β Hidden Fields & variables.
In the Hidden Fields section, type
hutkin the field input (the preset list includes UTM parameters but nothutk).Click Save.
Add it as a hidden field, not as a variable β hidden fields and variables are separate sections, and the embed script fills hidden fields. The same settings panel is described in How to add custom variable in Youform?.
Embedded and popup forms
Attribution works the same way on both surfaces, and you don't add any JavaScript for it β the cookie handoff is part of the embed.
Inline JS embed β our embed script on your page reads the
hubspotutkcookie and sends the value into the form.Popup embed β the popup script appends
hutk=<cookie value>to the form URL when the popup opens and delivers it to the hidden field.
Get the inline or popup embed code from your form's Share tab. See Embedding a Youform on Your Website for the embed options.
Consent timing and unavailable tracking
HubSpot's tracking code can load asynchronously or wait for the visitor's consent choice, so the cookie may not exist when the form opens. Our embed script checks for the cookie about once a second for roughly 30 seconds and listens for HubSpot consent events. If the cookie appears during that window, the value is delivered to the form.
If no hubspotutk cookie ever appears β tracking not installed, blocked, or consent withheld β no hutk value is added. The field stays empty and no error is shown; this is the expected fallback, not a configuration problem.
How existing values are handled
An existing hutk value is preserved. If the form URL already contains a hutk parameter, the cookie value is not applied β the existing value wins.
Verify attribution in a test submission
Submit a test response and check the submission data for the hutk hidden field β hidden fields are included in submission payloads, so the value appears alongside the answers.
These timing cases match how the script behaves:
Cookie already present β visit your page with HubSpot tracking active and consent granted, submit the form, and confirm the
hutkvalue matches the cookie.Consent granted after the form opens β open the form, accept the consent banner, and submit; the value is delivered once the cookie appears.
Tracking or consent unavailable β expect an empty
hutkvalue. That's the expected fallback.
Send the captured value to HubSpot
The hutk value is part of the submission, so you can forward it with a webhook or a Zapier/Make flow. Youform connects to HubSpot through Zapier or Make β see the Integrations article for the connection options.