On this page
What this issue is
Hidden fields are form inputs visitors never see, such as <input type="hidden" name="lead_source">. They carry data like UTM parameters, the Google click ID (gclid), the landing page or a campaign name into your CRM.
The problem appears when two scripts both write to the same field. Your script fills it correctly, then a later one (a form plugin, a page builder, a tracking tag, a cache or a theme script) sets it back to empty or to a default. The last write wins, and that is what gets submitted.
This differs from a field that is never populated at all (see CNV-008). Here the value is set, then lost.
Why it costs you leads or sales
The lead is not lost, but its source is. Sales sees a contact with no campaign, no keyword and no click ID. You cannot tell which ads produce real leads, offline conversion uploads to Google Ads fail without a gclid, and routing rules based on a hidden value (region, service, owner) send leads to the wrong place or nowhere.
Because the form still submits, nobody gets an error. The damage shows up weeks later as a report full of Direct or Unknown.
- Visitor landsURL has utm and gclid
- Your script fills fieldValue is correct
- Later script resets itField becomes blank or default
- Form submittedBlank value sent
- CRM recordNo source or click ID
The field is filled correctly, then overwritten before submit.
The form submits, but one value is missing from what the CRM receives.
How to check if your site has it
Open the page with test parameters
Visit your form page with a URL such as
?utm_source=test&utm_campaign=hidden-check&gclid=TEST123.Inspect the hidden field
Right-click the form, choose Inspect, and find the hidden input in the Elements panel. Note its value right after load.
Watch it change
Wait a few seconds, click into the form, and look again. Changed values flash in the panel. If the value goes blank, something overwrote it.
Find the writer
Right-click the input in Elements, choose Break on, then Attribute modifications. Reload and the debugger stops on the script that changes it.
Compare with the CRM
Submit a test lead and open the record. If the field is empty there but filled on the page, the overwrite happens at or before submit.
How to fix it
The fix is always the same idea: make sure only one thing owns the field, and that it writes after any reset. The exact place depends on your platform.
Use the plugin's own dynamic value
In forms like Gravity Forms, Contact Form 7 add-ons or Fluent Forms, set the hidden field's default to a dynamic parameter (for example the field's Allow field to be populated dynamically option) instead of a custom script.
Disable duplicate scripts
If a UTM plugin and a theme snippet both fill the field, remove one. Test by deactivating plugins one at a time on a staging copy.
Exclude the page from caching
If your cache plugin serves a stale form, exclude the landing page or exclude query strings from cache rules.
Find tags that write to the field
In Preview mode, check which Custom HTML tags set input values. Look for tags that fire on Window Loaded or DOM Ready.
Fire your fill tag later and once
Fire the fill tag on Window Loaded, and set Tag firing options to Once per page. If a form rebuilds after that, trigger on the form's visible or interaction event instead.
Remove the competing tag
Pause any other tag that sets the same field, then republish.
Check custom code
In Project settings > Custom code and each page's settings, look for scripts that set input values.
Move your script to before the closing body tag
Place the fill script in the Footer code so it runs after the form exists, and keep only one script writing to each hidden field.
Review custom code elements
In the funnel or form builder, check Custom JS/HTML elements and the page's tracking code for scripts that set hidden fields.
Use the built-in hidden field where possible
Add a Hidden field to the form and map it to a custom field, then keep one script for filling it. Test in the live page, not just the preview.
Fill the field after the form is ready
Set the value once the form exists and again just before submit, so a late reset cannot win. See the snippet below.
Stop other code writing to it
Search your codebase for the field's name and remove or guard other writers.
function getParam(name) {
return new URLSearchParams(window.location.search).get(name) || '';
}
function fillHidden(form) {
var map = {
utm_source: getParam('utm_source'),
utm_campaign: getParam('utm_campaign'),
gclid: getParam('gclid')
};
Object.keys(map).forEach(function (key) {
var input = form.querySelector('input[name="' + key + '"]');
if (input && map[key]) { input.value = map[key]; }
});
}
document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('form').forEach(function (form) {
fillHidden(form);
// Capture phase: runs before most other submit handlers.
form.addEventListener('submit', function () { fillHidden(form); }, true);
});
});Before
- Two scripts write to the same field
- Value is reset after load
- CRM shows blank source and gclid
After
- One script owns the field
- Value is set again just before submit
- CRM record carries the right source and gclid
How to confirm it's fixed
Repeat the test URL
Open the form page with
?utm_source=test&utm_campaign=hidden-check&gclid=TEST123in a fresh private window.Submit a test lead
Fill the form with a clearly labelled test contact and submit it.
Check the payload
Open the CRM record or the webhook log and confirm utm_source, utm_campaign and gclid hold your test values.
Test other paths
Repeat on mobile, in a popup version of the form and after a multi-step form advances, as those often rebuild the fields.
How to prevent it happening again
- Give each hidden field exactly one owner (plugin, tag or script).
- Document which field names your CRM expects and which script fills each.
- Retest a lead with UTM parameters after every plugin, theme or tag update.
- Retest after adding a new popup, chat widget or form step.
- Keep cache rules from serving stale forms on landing pages.
- Set up an automated test that checks the CRM payload, not just that the form submits.
Day 1
A plugin update adds its own script that resets form fields on load.
Day 2
Leads keep arriving, so nobody notices anything wrong.
Week 3
A report shows paid leads marked Unknown or Direct.
Week 3
The overwriting script is found and removed; the value is set again on submit.
How FunnelGuard handles this
FunnelGuard detects this issue today. A robot visitor opens your form page on a schedule, fills and submits the form as a test lead, and checks the payload sent to your CRM webhook. The check looks for the expected hidden field values in that payload (a payload_contains check). If a value you expect, such as a source or campaign, arrives blank or missing, the check fails.
A failure is re-checked from a second region before one alert goes out, by email, Slack, Teams, WhatsApp, webhook or PagerDuty, with a screenshot and a likely cause. Test traffic is marked with utm_source=funnelguard and fg_test=1, so you can filter it out of reports. It never bypasses CAPTCHAs or bot protection.
The Free plan covers 1 site and 2 journeys with daily checks and no card. Paid plans start at $39/month with a 3-day free trial, and a free read-only website audit is available.
Questions people ask
Why is my hidden field empty when the form is submitted?
Usually a second script sets the field after yours, or the form is rebuilt after your script ran. The last write wins, so a blank value is submitted. Inspect the field in your browser and use Break on attribute modifications to find the script.
Why does my gclid hidden field show in the page but not in the CRM?
The value may be reset between page load and submit, or the CRM field mapping may not match the field name. Submit a test lead with a test gclid in the URL and compare the form payload with the CRM record to see where it disappears.
How do I find which script overwrites a hidden input?
Open DevTools, find the input in the Elements panel, right-click it and choose Break on, then Attribute modifications. Reload the page and the debugger pauses on the code that changes the value.
How do I make sure my hidden field value is not overwritten?
Let one script own the field, and set the value again on the form's submit event using a capture-phase listener. That way a late reset cannot change what is sent.
Can caching cause hidden field values to be wrong?
Yes. A cached page can serve a stale form or old script state. Exclude landing pages with query strings from cache or fill the fields client-side so they do not depend on the cached HTML.
Can a form plugin reset hidden fields on its own?
Yes. Some form plugins and page builders re-render the form after load, for example when a popup opens or a multi-step form advances, and that can clear values set earlier. Fill the field after the re-render or on submit.
Can FunnelGuard detect a hidden field being overwritten?
Yes. It submits a test lead on a schedule and checks that the payload sent to your CRM webhook contains the values you expect. If a value is missing or blank, you get an alert with a screenshot and a likely cause.
Related issues
- CNV-008Hidden UTM/gclid fields not populatedFix guide
- CNV-002Form field renamed or removed so the lead loses dataFix guide
- CNV-003Required field marked optional (or optional marked required)Fix guide
- CNV-018Autofill fills wrong fields (bad autocomplete attributes)Fix guide
- CNV-021Form renders twice (duplicate embed)Fix guide
- CNV-001Form missing from the landing page entirelyFix guide