Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Hidden UTM and gclid fields not populated: how to fix it

CNV-008High impactDetectedBy FunnelGuardPublished Updated
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.

Where the campaign data gets lost
  1. Ad clickURL has utm_* and gclid
  2. Landing pageParameters in the address bar
  3. Hidden fieldsNo script fills them
  4. CRM recordSource and gclid blank
  5. Ad reportingLead can't be matched

The visitor arrives with tracking parameters, but the form submits without them.

Leads with a known sourceExample numbers
Leads with a known source (example)Before fix: 12 %; After fix: 94 %036721294Before fixAfter fix%

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

Test it by hand in two minutes
  1. 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

  2. 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.

  3. 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.

  4. 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).

Store UTMs and gclid, then fill hidden fieldsjavascript
(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 });
})();
Set it up on your platform
  1. 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.

  2. 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.

  3. 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.

Then check the rest of the path
  1. Map the fields in your CRM

    Make sure each hidden field maps to a CRM property. An unmapped field is dropped silently.

  2. Check redirects

    Test that your landing page URL keeps its parameters after any redirect (http to https, www, trailing slash).

  3. Avoid overwriting

    Only fill empty fields, as the snippet does, so a later visit without parameters doesn't wipe the original source.

How parameters disappear before the form

A redirect or page change drops the URL parameters, so the form has nothing to read.

How to confirm it's fixed

Confirmation checklist
  • 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.

Habits that keep it working
  • 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
Lead record in the CRM

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.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: UTM persistence into hidden fields.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.