How do UTM hidden fields get campaign data into your CRM?
UTM hidden fields get campaign data into your CRM by carrying values the visitor never sees along with the form submission. A small script reads utm_source, utm_medium, utm_campaign, utm_term and utm_content from the landing URL, stores them, and writes them into hidden inputs, so the CRM receives the campaign next to the name and email.
Analytics tools already see UTMs, so why bother? Because GA4 reports sessions, not people. Sales needs to know which campaign produced a specific lead, and that answer has to live on the contact record. Hidden fields are the simplest way to put it there, on any form builder.
This guide is part of our hub on what B2B teams should measure on their marketing website. It assumes your UTMs already follow a naming convention. Here we cover the implementation: capture, storage, the form fields in Framer and Webflow, and the mapping to HubSpot or Salesforce.
Why do UTM values disappear before the form is submitted?
UTM values disappear because they only exist in the URL of the first page a visitor lands on. As soon as they click to another page, the query string is gone, and if they come back tomorrow through a bookmark, the form has nothing to read.
B2B visitors rarely convert on the landing page. A typical path is an ad to a blog post, then a product page, then pricing, then the demo form, sometimes across several visits. A script that only reads the current URL captures UTMs for the small share of people who convert on the first page and records nothing for everyone else.
The fix is to save the values on arrival and read them back at submission. That raises one decision you should make on purpose: whether you want the first campaign that brought the person, the last one before they converted, or both. We recommend both, in separate fields, because sales and marketing usually ask different questions of them.
Where should you store UTMs: cookie, localStorage or sessionStorage?
Store UTMs in first-party storage on your own domain: a first-party cookie or localStorage for values that should survive across visits, and sessionStorage only if you care about the current visit alone. Each has trade-offs worth knowing before you write the script.
Storage | Survives a new visit? | Shared across subdomains? | Best for |
|---|---|---|---|
sessionStorage | No, cleared when the tab closes | No | Last-touch within one visit |
localStorage | Yes, until cleared | No, one origin only | First-touch on a single domain |
First-party cookie | Yes, until it expires | Yes, if set on the parent domain | Sites split across www and app subdomains |
Two cautions. Safari's tracking prevention limits how long script-set storage lasts, so a visitor who returns weeks later may arrive with nothing stored; treat long first-touch windows as best effort. And depending on where your visitors are, storing attribution data may fall under consent rules. Check with whoever owns privacy for your company, and if your consent banner blocks analytics until opt-in, decide whether this script runs before or after consent. This is a process note, not legal advice.
How do you set up UTM hidden fields in Framer?
In Framer, add an Input to your Form component, select it and turn on the Hidden property, then give it a name such as utm_source. Framer's help docs warn that an input hidden with the Visible property is left out of submissions entirely, so always use Hidden.
Hidden inputs don't fill themselves. Framer's docs say you can use a code override to pass UTM values into them; a component from the Framer Marketplace that stores parameters and writes them into the form is another route. The override reads your stored values when the form mounts and sets each matching input.
Framer also offers campaign tracking that captures utm_source, utm_medium, utm_campaign, utm_term, utm_content and the Google Ads click ID with every native form submission, with no hidden fields needed. Framer's help center lists it as an Enterprise plan feature, so check your plan before you build an override you may not need. From there, send submissions to your CRM through Framer's form integrations or a webhook. If you'd rather hand the build over, our Framer development service includes form and CRM wiring.
How do you add UTM hidden fields to a Webflow form?
In Webflow, place a Code Embed element inside the form block and write one hidden input per parameter, each with a name attribute that matches the field you want in the CRM. Then add a script in the site-wide custom code that saves UTMs on every page and fills those inputs when a form is present.
Put the storage script in site-wide footer code rather than on one page, because visits often start on blog posts or CMS templates, not the page with the form. Custom code depends on your site plan, so check Webflow's current plan page. Avoid hiding regular text fields with CSS; a true hidden input keeps the form layout clean and makes it obvious which fields are tracking fields.
How the data reaches your CRM depends on the connection. If you use HubSpot's app for Webflow, the native form's fields are mapped to HubSpot properties; our guide to connecting Webflow forms to HubSpot walks through it. If you route through Zapier or Make, map each hidden field explicitly in the automation.
What the storage script does, in plain steps
The script is short, and any developer can write it from this description.
On every page load, it checks the URL for the five UTM parameters. If any are present, it saves them as the last-touch set, overwriting the old last-touch values. If no first-touch set exists yet, it saves the same values as first-touch too, and never overwrites them afterwards.
When a form is on the page, it finds each hidden input by name (for example first_utm_source or last_utm_campaign) and writes the stored value into it. It also writes the landing page URL and the referrer if you've added fields for them. If nothing is stored, it leaves the fields empty rather than writing a placeholder such as "none", so empty values stay easy to filter in reports.
How do you map UTM fields to HubSpot or Salesforce?
Map UTM fields to custom CRM properties you create for the purpose, such as First UTM Source and Last UTM Campaign, and point each hidden input at one of them. Don't write over the source fields your CRM calculates itself, because you'll lose the CRM's own attribution and confuse reports.
In HubSpot, create single-line text contact properties for each UTM field and match the hidden input names to their internal names. HubSpot's tracking code records its own original source properties separately, which gives you a useful cross-check. Our HubSpot integration page covers how we set these up.
In Salesforce, add custom text fields to the Lead object and map them in whichever integration receives the form. Then map the same fields onto Contact and Opportunity in lead conversion settings, or the campaign data stays behind when a lead converts. Our Salesforce integration page explains the setup.
What are the steps to set it up end to end?
The full setup takes six steps, and the order matters: create the CRM properties before you build the forms, so you know the exact field names to use.
Agree the field list
First and last values for the five UTMs, plus landing page and referrer. Write the exact names in one shared sheet.
Create the CRM properties
Add custom text properties in HubSpot or custom Lead fields in Salesforce, with first-touch fields set not to be overwritten.
Add the storage script
Install it site-wide so every entry page saves UTMs, and respect your consent setup.
Add hidden fields to every form
Framer: Input with the Hidden property. Webflow: hidden inputs in a Code Embed. Names must match the sheet.
Connect the form to the CRM
Map each hidden field to its property in the native app, webhook or automation tool.
Test with real submissions
Visit with test UTMs, browse two pages, submit, and check the contact record. Repeat for each form and a second visit.
How do you check the data once it's live?
Check the data by comparing CRM contacts against GA4 sessions for the same campaign each week for the first month. The counts won't match exactly, since GA4 counts sessions and the CRM counts people, but a campaign with traffic and no tagged contacts points to a broken form or a missing field.
Expect gaps that no script can close: people who arrive from AI assistants, private channels or a colleague's recommendation carry no UTMs at all. Pair hidden fields with a "How did you hear about us?" field to catch what tracking misses, and read our guide to B2B attribution when buyers research in ChatGPT for how to report both side by side. If you're rebuilding your site, add UTM capture to the checklist for migrating forms without losing leads.
