On this page
What this issue is
A hidden field is a form input visitors don't see. Marketers use them to store where a lead came from: utm_source, utm_medium, utm_campaign, and gclid (the click ID Google Ads adds to your ad links). The idea is that the form submits these values along with the name and email.
Why it costs you leads or sales
You don't lose the lead itself. You lose the link between the lead and the ad. Without it, your CRM can't show which campaign produced which customer, and you can't upload offline conversions to Google Ads, which need the gclid.
- Ad clickURL has utm_* and gclid
- Landing pageParameters in the address bar
- Hidden fieldsNo script fills them
- CRM recordSource and gclid blank
- Ad reportingLead can't be matched
The visitor arrives with tracking parameters, but the form submits without them.
Example: share of paid leads in the CRM that have a campaign recorded, before and after fixing hidden fields.
How to check if your site has it
Build a tagged URL
Add parameters to your landing page, for example https://example.com/landing?utm_source=test&utm_medium=cpc&utm_campaign=check&gclid=TEST123
Inspect the hidden fields
Open the page, right-click the form, choose Inspect, and search for input type="hidden". Check whether the value attributes contain test, cpc, check and TEST123.
Click through to a second page
Load the tagged URL, then navigate to another page with a form (or the thank-you route). The values should still fill in, because the parameters are no longer in the URL.
Submit and check the lead
Submit the form and open the lead in your CRM or email notification. The source, campaign and gclid should show your test values.
How to fix it
The reliable pattern has two parts: store the parameters when the visitor first lands, then fill every hidden field from the stored values. The snippet below does both and also handles forms added to the page late (popups, embeds).
(function () {
var keys = ['utm_source','utm_medium','utm_campaign','utm_term','utm_content','gclid'];
var params = new URLSearchParams(window.location.search);
// 1. Save any parameters present in the URL (30 days)
keys.forEach(function (k) {
var v = params.get(k);
if (v) {
document.cookie = k + '=' + encodeURIComponent(v) + ';path=/;max-age=2592000;SameSite=Lax';
}
});
function getCookie(name) {
var m = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
return m ? decodeURIComponent(m[1]) : '';
}
// 2. Fill hidden inputs whose name or id matches
function fill() {
keys.forEach(function (k) {
var val = getCookie(k);
if (!val) return;
document.querySelectorAll('input[name="' + k + '"], input[id="' + k + '"]').forEach(function (el) {
if (!el.value) el.value = val;
});
});
}
document.addEventListener('DOMContentLoaded', fill);
window.addEventListener('load', fill);
new MutationObserver(fill).observe(document.documentElement, { childList: true, subtree: true });
})();Add hidden fields to the form
In your form plugin, add hidden fields named utm_source, utm_medium, utm_campaign, utm_term, utm_content and gclid. Gravity Forms and WPForms can fill them via dynamic population or a default value of a smart tag; check your plugin's docs for the exact option.
Load the script site-wide
Add the snippet to the footer with a header and footer plugin, or your theme's script settings, so it runs on every page.
Match field names
If your plugin generates different input names, change the selector in the script, or set the field's parameter name in the plugin.
Create a Custom HTML tag
Paste the snippet inside script tags in a new Custom HTML tag.
Trigger on All Pages
Use the All Pages trigger (or Page View - DOM Ready) so the values are stored on landing and filled once forms exist.
Preview and test
Use Preview mode with a tagged URL, confirm the tag fires, then publish.
Add hidden inputs
Webflow has no hidden field element, so add an Embed element inside the form with input type="hidden" name="utm_source" and so on for each field.
Add the script
In Site settings > Custom code > Footer code, paste the snippet in script tags, then publish.
Add hidden fields
In the form builder, add Hidden Field elements and set the query key to the matching parameter name (for example utm_source or gclid).
Check the embed
If the form is embedded in an iframe on another site, the parent page's URL parameters may not reach it. Test with a tagged URL and use the script on the parent page if needed.
Add hidden fields
Wix Forms offers hidden fields in some versions. If yours doesn't, use Velo to read wixLocation.query and write values into your form or submission data.
Store across pages
Save the values with wix-storage session so they survive navigation to the form page.
Use form hidden data
Squarespace form blocks don't offer hidden fields in every plan. Check Advanced settings in the form block. If unavailable, use a third-party form with hidden fields.
Add the script
Paste the snippet in Settings > Advanced > Code Injection > Footer.
Add hidden inputs
Put <input type="hidden" name="utm_source"> and the other fields inside your form element.
Include the script on every page
Load it from your shared layout so values are stored on the first page and filled wherever a form appears.
Read the fields on the server
Make sure your form handler accepts and saves these field names and passes them to the CRM.
Map the fields in your CRM
Make sure each hidden field maps to a CRM property. An unmapped field is dropped silently.
Check redirects
Test that your landing page URL keeps its parameters after any redirect (http to https, www, trailing slash).
Avoid overwriting
Only fill empty fields, as the snippet does, so a later visit without parameters doesn't wipe the original source.
A redirect or page change drops the URL parameters, so the form has nothing to read.
How to confirm it's fixed
- Hidden inputs show your test values when you load a tagged URL
- Values still fill after you click to another page
- A test submission shows source, campaign and gclid in the email notification
- The same values appear on the CRM contact record
- A visit without parameters does not erase stored values
- Works on mobile and in a private window
How to prevent it happening again
This usually breaks after a change: a new form plugin version, a rebuilt landing page, a renamed field, a new redirect rule or a consent banner update. Because the lead still arrives, nobody sees the damage until reports look wrong.
- Keep field names identical in the form, script and CRM mapping
- Retest with a tagged URL after any form, theme or redirect change
- Document the parameter names you capture
- Review the share of leads with a blank source each month
- Use one script site-wide rather than one per page
Hidden fields empty
- Source: blank
- Campaign: blank
- gclid: blank
- Offline conversion upload impossible
Hidden fields populated
- Source: google
- Campaign: spring-offer
- gclid: saved
- Lead matched to the ad click
How FunnelGuard handles this
FunnelGuard detects this issue today. Its check covers UTM persistence into hidden fields: a robot visitor opens your landing page with tracking parameters, moves through the journey, and checks whether the hidden fields end up holding those values.
Test visits are marked with utm_source=funnelguard and fg_test=1, so they are easy to spot and filter. If the check fails, it is re-run from a second region before one alert goes out, with a screenshot and a likely cause. You can start on the Free plan (1 site, 2 journeys, daily checks, no card), or try a paid plan free for 3 days.
Questions people ask
Why are my hidden UTM fields empty in my form submissions?
Usually nothing copies the URL parameters into the hidden fields, or the parameters were gone by the time the form loaded. Add a script that saves the values on landing and fills the fields on every page with a form, and make sure field names match.
How do I pass gclid into a hidden form field?
Read gclid from the URL with URLSearchParams, store it in a cookie or storage, and write it into an input named gclid. Then map that field to a CRM property so it is saved with the lead.
Why do UTM parameters disappear when the visitor goes to another page?
Parameters only exist in the URL of the first page. If the form is on a later page, you need to store them (cookie or sessionStorage) on landing. Redirects can also strip them, so test the final URL.
Do I need a cookie to store UTM parameters?
Not necessarily. sessionStorage works for one visit and avoids a persistent cookie, but it is lost when the tab closes. Whichever you choose, check whether your consent rules apply.
Why does my CRM show the source but not the gclid?
The gclid field is probably not mapped, named differently, or not added to the form at all. Check the form field name, the script selector and the CRM property mapping.
How can I test if my hidden fields are populated?
Open your landing page with a tagged URL such as ?utm_source=test&gclid=TEST123, inspect the hidden inputs, then submit the form and check the lead record. Repeat after clicking to a second page.
Can a later script overwrite my hidden field values?
Yes. Another script or a visit without parameters can replace good values with blanks. Fill only empty fields and keep the stored original values.
Related issues
- CNV-009Hidden field value overwritten by a later scriptFix guide
- CNV-002Form field renamed or removed so the lead loses dataFix guide
- CNV-001Form missing from the landing page entirelyFix guide
- CNV-021Form renders twice (duplicate embed)Fix guide
- CNV-018Autofill fills wrong fields (bad autocomplete attributes)Fix guide
- CNV-003Required field marked optional (or optional marked required)Fix guide