On this page
What this issue is
A hidden field is a form input the visitor never sees. Marketers use it to store where the lead came from, such as utm_source, utm_medium, utm_campaign, gclid or a plain "lead source" value. The form sends those values to your CRM with the name and email.
- Ad clickURL has utm_source and gclid
- Landing pageValues not saved anywhere
- Form pageHidden fields stay empty
- CRM recordLead source blank
- ReportingLead counted as direct or unknown
The break happens between the landing page and the form submit. Everything after it carries an empty value.
Why it costs you leads or sales
Example: share of CRM leads with a filled source field before and after fixing the hidden fields. Your numbers will differ.
How to check if your site has it
Open a private window with test UTMs
Visit your landing page with
?utm_source=test&utm_medium=cpc&utm_campaign=hidden-check&gclid=abc123added to the URL.Inspect the form
Right-click the form, choose Inspect, and search for
type="hidden". Check whether the value attributes of your UTM fields are filled.Navigate before submitting
Click through to a second page, then to the form, the way a real visitor would. Check the fields again.
Submit and check the CRM
Submit with a test email and open the new record. Confirm each source field holds the test value, not blank.
How to fix it
| Cause | Symptom | Fix |
|---|---|---|
| UTMs not saved | Fields filled only if the form is on the landing page | Store values in a cookie or sessionStorage on first visit |
| Script runs too early | Form loads later, fields stay empty | Fill fields on form load or watch for the form to appear |
| Name mismatch | Field filled on the page but blank in CRM | Match the field name or ID the form tool expects |
| Redirect strips parameters | UTMs missing on landing page | Keep the query string in redirects |
| Field not mapped | Value sent but CRM property empty | Map the hidden field to a CRM property |
(function () {
var keys = ['utm_source','utm_medium','utm_campaign','utm_term','utm_content','gclid','fbclid'];
var params = new URLSearchParams(window.location.search);
keys.forEach(function (k) {
var v = params.get(k);
if (v) sessionStorage.setItem(k, v);
});
function fill() {
keys.forEach(function (k) {
var v = sessionStorage.getItem(k);
if (!v) return;
document.querySelectorAll('input[name="' + k + '"], input[id="' + k + '"]').forEach(function (el) {
if (!el.value) {
el.value = v;
el.dispatchEvent(new Event('input', { bubbles: true }));
}
});
});
}
fill();
new MutationObserver(fill).observe(document.documentElement, { childList: true, subtree: true });
})();Add a hidden field with a dynamic value
Many form plugins support this. In Gravity Forms, add a Hidden field, tick Allow field to be populated dynamically and set the parameter name to utm_source. In Contact Form 7 or WPForms, use the plugin's hidden field and the script above to fill it.
Load the script site-wide
Add the snippet through a header and footer plugin or your child theme so it runs on every page, not only the form page.
Map the field
In the CRM integration settings, map each hidden field to a CRM property.
Add hidden inputs to the form
In Online Store > Themes > Edit code, add
<input type="hidden" name="contact[utm_source]" id="utm_source">inside the form section. Custom fields on contact forms use the contact[...] name pattern.Add the script to theme.liquid
Paste the snippet before the closing body tag so it runs on every page.
Check the notification
Submit a test and confirm the values appear in the email or in the app that receives the lead.
Create a Custom HTML tag
Paste the snippet inside script tags and fire it on All Pages. Use the DOM Ready trigger so the form exists.
Handle late forms
The MutationObserver in the snippet covers popups and forms loaded after the page.
Preview and test
Use Preview mode with test UTMs and check the field values in the page inspector.
Add hidden inputs
Use an Embed element inside the form block with
<input type="hidden" name="utm_source" id="utm_source">for each value.Add the script
Under Site settings > Custom code, paste the snippet in the footer code area.
Publish and test
The script only runs on the published site, not in the Designer, so test the live URL.
Add hidden fields to the form
In the form builder, add Hidden Field elements and connect them to custom fields. Hidden fields can read URL parameters by using the query key as the field's value source where the builder offers it.
Add the script for returning visitors
If the form sits on a later page, add the snippet in the page's custom code so values from the first page are kept.
Check the contact record
Submit a test and confirm the custom fields are filled on the contact.
Use Wix Forms with a hidden field
Add a hidden field in the form settings where available, or use Velo to set a value on submit.
Read the URL with Velo
Enable Dev Mode, use
wixLocation.queryto read the UTMs and store them withwix-storage-frontendsession storage.Write the values on submit
Set the hidden field value from storage in the form's onSubmit handler.
Check what the form supports
Squarespace's native form blocks have limited hidden field support. Check whether your plan and version offer it.
Use Code Injection
Add the snippet under Settings > Advanced > Code Injection if you use a form that accepts hidden inputs.
Consider a third-party form
If hidden fields aren't possible, embed a form from your CRM that supports them.
Add hidden inputs
Include
<input type="hidden" name="utm_source">and the other fields in your form markup.Include the script on every page
Load it in your base template, so values are saved on the landing page, not only on the form page.
Accept the fields on the server
Make sure your back end reads these fields and passes them to the CRM API with the right property names.
Before
- UTMs read only on the landing page
- Form loads after the script runs
- CRM source field blank or 'Direct'
After
- UTMs saved on first visit
- Fields filled when the form appears
- CRM shows source, medium and campaign
How to confirm it's fixed
- Visiting with test UTMs fills the hidden fields in the page inspector
- The values are still there after clicking to another page
- A test submission creates a CRM record with source, medium and campaign filled
- The test works on mobile as well as desktop
- Forms in popups and embeds are filled too
- A visit without UTMs leaves the fields blank or on your chosen default
How to prevent it happening again
- Keep one documented list of hidden field names and the CRM properties they map to
- Re-test after any change to forms, themes, consent banners or redirects
- Add the script in one place only, so it isn't duplicated or removed by accident
- Keep query strings on redirects and short links
- Review the CRM for blank source values every month
- Schedule an automated test submission with UTMs
How FunnelGuard handles this
Questions people ask
Why are my hidden form fields empty?
The most common reasons are that the UTMs were never saved after the landing page, the script ran before the form loaded, or the field name doesn't match. Check the page inspector to see whether the value is set before you submit.
Why is my UTM hidden field not populating?
The script usually can't find the field, or the visitor reached the form on a different page where the URL no longer has UTMs. Save the values in sessionStorage or a cookie on the first page and fill the fields when the form appears.
How do I capture UTM parameters in a hidden form field?
Add a hidden input for each parameter, read the values from the URL with JavaScript, store them, and write them into the inputs. Then map each field to a property in your CRM.
Why does the lead source show as Direct in my CRM?
Direct often means no source value arrived. UTMs may have been stripped by a redirect, lost between pages, or never written to the hidden field. Test with a tagged URL and check each step.
Do hidden fields work in popups and embedded forms?
Only if the script fills them after the form loads. Popups and iframes appear later or live in a separate document, so use a MutationObserver or the form tool's own hidden field setting.
Why is gclid empty in my form submissions?
The gclid only exists on the first landing URL after an ad click. If you don't store it, it is gone by the time the visitor reaches the form. Save it on arrival and fill a hidden field from storage.
How can I test hidden form fields without waiting for real leads?
Open your page with test UTMs, fill the form with a test email and check the CRM record. An automated check such as FunnelGuard's UTM persistence test can repeat this on a schedule.
Related issues
- DLV-077HubSpot contact created without UTM / original sourceFix guide
- DLV-096gclid/fbclid not stored on the CRM record for offline conversionsFix guide
- DLV-088Fields unmapped: phone lands in notes or nowhereFix guide
- DLV-078HubSpot form submission not attributed to the pageFix guide
- DLV-100CRM custom field deleted or renamed, sync errorsFix guide
- DLV-076Contact not created in the CRM after submitFix guide