UTM Parameters Not Passing to Your Form? 6 Causes, Tested

web development
Three tan leather suitcases on a concrete floor against a slate grey-green wall, two with red luggage tags and the third with a snapped string and its tag lying on the floor, illustrating UTM parameters lost before a form submission
The campaign tag is there when the visitor lands. Most forms lose it one click later.

Why aren't my UTM parameters passing to my form?

UTM parameters stop reaching your form because most capture scripts read the URL of the page the form sits on, and UTMs only exist on the landing page URL. The moment a visitor clicks to your contact page, opens the form in a new tab, or comes back two days later, the hidden fields submit empty. Your CRM fills up with leads marked "direct" or "unknown," and paid campaigns look worse than they are.

We tested the snippet most tutorials hand out (read location.search, fill the fields on page load) against six everyday visitor paths. It captured the UTMs in two of the six. A version that saves the values on landing and fills fields from storage captured all six. The details, and that script, are below.

How we tested it

We built a small test site with a home page, a contact page and a page where the form is injected 1.2 seconds after load, the way embedded form builders behave. Each page had hidden utm_source, utm_medium and utm_campaign fields. We drove it with headless Chromium (Playwright 1.60), landing on ?utm_source=facebook&utm_medium=paid_social&utm_campaign=fall_promo, and read the hidden field values after each step.

For the caching problem we ran a small local server that fills hidden fields on the server and caches pages the way WP Rocket documents its defaults. That part is a simulation of documented behavior, not a test of the plugin itself. We say so where it comes up.

Cause 1: The visitor clicked to another page first

This is the big one. Paid traffic lands on a service page or the home page, the visitor reads, then clicks "Contact." The URL is now /contact with no query string, and the naive script finds nothing to copy.

  • Landing page with the form on it: UTMs captured.
  • Clicked from the landing page to the contact page: all three fields empty.
  • Came back later by typing the URL: empty.
  • Came back through a second ad (Google, utm_medium=cpc): captured, but only the second campaign. Nothing records that Facebook brought them first.

If your form is not on the exact page the ad points to, a URL-only script loses most of your paid leads. It looks fine in a quick test because whoever builds it usually tests by pasting the tagged URL straight onto the form page.

Cause 2: The form loads after your script runs

Embedded forms, popups and multi-step widgets often render after DOMContentLoaded. A script that fills fields on that event finds no fields, does nothing, and never runs again. In our test, the form that appeared 1.2 seconds after load submitted with every UTM field empty, even though the UTMs were sitting in the URL of that same page.

This is also the usual story behind "it works sometimes" when the script is deployed through Google Tag Manager. Tag timing shifts with page speed, so on a fast load the form wins the race and on a slow one it loses. The fix is to keep filling: watch the page with a MutationObserver and fill any matching field as soon as it exists. If your form is split into steps, the same idea applies to every step (we cover carrying values between steps in our multi-step vs single-step form guide).

Cause 3: Page caching hands visitors someone else's UTMs

This one produces wrong data rather than missing data, which is worse.

Some form plugins fill hidden fields on the server. Gravity Forms' dynamic population, for example, reads the query string when the page is built. Its own documentation warns that aggressive caching can break it. Page caches commonly drop marketing parameters from the cache key so one tagged URL doesn't create thousands of cache files. WP Rocket's list of ignored parameters includes utm_source, utm_medium, utm_campaign, utm_term, utm_content, gclid and fbclid by default.

Put those two together and the first visitor primes the cache. In our simulation:

  • First request, ?utm_source=facebook: cache miss, hidden field = facebook.
  • Second request, ?utm_source=google&gclid=…: cache hit, hidden field = facebook.
  • Third request, no parameters at all: cache hit, hidden field = facebook.
  • Fourth request, ?utm_source=newsletter: cache hit, hidden field = facebook.

Every lead after the first gets credited to whatever campaign warmed the cache. If one source suddenly "drives" almost all of your form leads, check this before celebrating. The clean fix is to stop prefilling UTM fields on the server and fill them in the browser, so the cached HTML stays neutral.

Cause 4: The form opens in a new tab and sessionStorage stays behind

A lot of tutorials save UTMs to sessionStorage. It survives clicks within one tab, and in our test the same-tab click to the contact page worked. But when the visitor opened the contact page through a target="_blank" link, the new tab started with empty sessionStorage and the field submitted blank. A fresh tab opened later was blank too, and sessionStorage is cleared when the tab closes, so every return visit is lost.

Use localStorage or a first-party cookie with an expiry you choose. Both are shared across tabs on the same site.

Cause 5: The form lives in an iframe or on another domain

A script on your page can't reach into an iframe served from another domain. Iframe embeds from form builders, scheduling tools and quiz apps all fall in this group. Your script runs, the fields it's looking for are inside someone else's document, and nothing gets filled.

The same goes for forms on a different domain or subdomain setup that doesn't share storage, such as a landing page on one domain and a checkout or booking page on another. The fix is to hand the values over explicitly. Most embed tools accept hidden-field values through the embed URL or an attribute, so read your stored UTMs and append them before the iframe loads. For cross-domain hops, decorate the outbound link with the stored values.

Cause 6: Safari, expiry and click IDs

Storage isn't forever. WebKit's Intelligent Tracking Prevention 2.2 caps cookies set through document.cookie to one day when a domain classified as cross-site tracking navigated the user to a URL with a query string or fragment, which describes a lot of ad clicks. Safari also limits script-written storage more generally. So a lead who returns from an iPhone a week later may submit blank even with a good script. That's a limit to report honestly, not a bug to chase forever.

Click IDs have their own problem: some browsers strip them from the URL before your page ever loads. We covered that separately in iOS 26 click ID stripping. UTMs survive that stripping, which is one more reason to capture them properly.

A capture script that passed all six tests

This is the script we ran in the tests above. It stores first-touch and last-touch values in localStorage for 90 days, records the landing page, and fills any matching hidden field, including fields that appear after load. It never overwrites a field that already has a value.

(function () {
  var KEYS = ['utm_source','utm_medium','utm_campaign','utm_term','utm_content','gclid','fbclid','msclkid'];
  var STORE = 'vx_attr';
  var MAX_AGE = 90 * 24 * 3600 * 1000;
  function read() {
    try { var d = JSON.parse(localStorage.getItem(STORE) || 'null');
      if (d && Date.now() - d.ts < MAX_AGE) return d; } catch (e) {}
    return null;
  }
  var p = new URLSearchParams(location.search), hit = {}, found = false;
  KEYS.forEach(function (k) { var v = p.get(k); if (v) { hit[k] = v; found = true; } });
  var saved = read() || {};
  var data = {
    first: saved.first || (found ? hit : null),
    last: found ? hit : (saved.last || null),
    landing: saved.landing || location.pathname,
    referrer: saved.referrer || document.referrer || '',
    ts: found || !saved.ts ? Date.now() : saved.ts
  };
  try { localStorage.setItem(STORE, JSON.stringify(data)); } catch (e) {}
  function fill(root) {
    var src = data.last || data.first || {};
    KEYS.forEach(function (k) {
      root.querySelectorAll('input[name="' + k + '"]').forEach(function (el) { if (!el.value) el.value = src[k] || ''; });
    });
    root.querySelectorAll('input[name="landing_page"]').forEach(function (el) { if (!el.value) el.value = data.landing; });
    root.querySelectorAll('input[name="first_utm_source"]').forEach(function (el) { if (!el.value) el.value = (data.first || {}).utm_source || ''; });
  }
  function run() {
    fill(document);
    new MutationObserver(function () { fill(document); }).observe(document.body, { childList: true, subtree: true });
  }
  if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); else run();
})();

Results with this script on the same six paths:

  • Landing page form: facebook / paid_social / fall_promo, landing page recorded.
  • Clicked to the contact page: same values, landing page still the original page.
  • Contact page in a new tab: same values.
  • Return visit, no parameters: same values.
  • Second tagged visit from Google: last touch updated to google / cpc / brand, first_utm_source still facebook.
  • Form injected 1.2 seconds late: filled.

Load it on every page, not just the one with the form, because the landing page is where the values are born. If you need consent before storing marketing data in your region, gate the setItem call behind your consent banner like any other marketing tag.

How do I check what my form actually sends?

Don't trust the page. Trust the request and the CRM record.

  1. Open a private window and land on a tagged URL, such as your home page with ?utm_source=test&utm_campaign=audit.
  2. Click to a different page, then open the form page in a new tab.
  3. In DevTools, run document.querySelectorAll('input[type=hidden]') and read the values.
  4. Submit, then find the request in the Network tab and confirm the UTM fields are in the payload.
  5. Open the lead in your CRM and check the fields are mapped and not overwritten by a later workflow.

Don't skip step 5. The form can send the values correctly while an automation later replaces them, or the CRM property has a different internal name and the value lands nowhere. When the source data is missing at this stage, everything downstream inherits it, which is the same root cause behind many Google Ads and GA4 mismatches and HYROS sales with no source.

Should the form send first touch or last touch?

Send both. First touch tells you which campaign found the customer. Last touch tells you which one brought them back to convert. Ad platforms, GA4 and most CRMs each report on a different model, and if the form only keeps one, you'll argue about the other with no data. Add a first_utm_source field (and more if you need them), keep utm_* as last touch, and include landing_page and the referrer. It's five extra hidden fields and it saves a lot of guessing in the monthly report.

Fix this before the holiday budget goes out

With Black Friday on November 27, ad budgets go up this month, and leads marked "direct" make paid campaigns look like they're failing. Most fixes here take an hour. Finding which of the six causes applies to your site is the slow part.

Want us to check it for you? We land on your site from tagged URLs, follow the paths real visitors take, and check what reaches your form and your CRM. Get a Free Automation Audit: you get your free initial audit report by email within 24 hours. If the gaps go deeper than the form, that's the tracking work our ads management and attribution team does every week.