leadstoolpack

Home › How-tos › The Secret Setups › Forms

The Secret Setups · 4 of 20

How to capture GCLID and UTMs in hidden form fields

Live guide · Checked 28 October 2026 · Updated 28 October 2026 · Checked every week against Forms's own help pages

Save the Google click ID and campaign tags when someone lands, and send them with the form, so your CRM knows which ad every lead came from.

Time
25 minutes
You will need
  • Edit access to your forms (to add hidden fields)
  • Google Tag Manager on your site
  • Auto-tagging on in Google Ads (Admin > Account settings)
Stuck?
Troubleshooting or ask us a question

Step by step

  1. Add hidden fields to your forms

    In your form builder add hidden fields with these exact names. Most builders call them Hidden fields:

    Text
    gclid
    utm_source
    utm_medium
    utm_campaign
    utm_term
    utm_content
  2. Save the values when people land

    Add this as a Tag Manager Custom HTML tag on All Pages. It keeps the click ID and campaign tags for 90 days (Google accepts offline conversions up to 90 days after a click):

    HTML
    <script>
    (function () {
      var KEYS = ['gclid', 'gbraid', 'wbraid', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content'];
      var q = new URLSearchParams(location.search), saved = {};
      try { saved = JSON.parse(localStorage.getItem('lead_src') || '{}'); } catch (e) {}
      var fresh = KEYS.some(function (k) { return q.get(k); });
      if (fresh) {
        saved = { at: Date.now() };
        KEYS.forEach(function (k) { if (q.get(k)) saved[k] = q.get(k); });
        try { localStorage.setItem('lead_src', JSON.stringify(saved)); } catch (e) {}
      }
      if (saved.at && Date.now() - saved.at > 90 * 864e5) saved = {};
      function fill() {
        KEYS.forEach(function (k) {
          document.querySelectorAll('input[name="' + k + '"]').forEach(function (el) { if (saved[k] && !el.value) el.value = saved[k]; });
        });
      }
      fill();
      new MutationObserver(fill).observe(document.body, { childList: true, subtree: true });
    })();
    </script>
  3. Map the fields in your CRM

    Make matching fields in your CRM (for example GCLID and UTM Campaign) and map the form's hidden fields to them, so every new lead keeps them.

  4. Test with a fake click ID

    Open your site with a test address, then send the form:

    Text
    https://www.example.com/?gclid=TEST123&utm_source=google&utm_campaign=test

    Check the new lead in your CRM shows TEST123 and test.

  5. Check the value survives a few pages

    Land on the test address, click to two other pages, then send the form. The click ID should still be there: that's what the 90-day saving is for.

  6. Publish

    Submit and Publish in Tag Manager. You're ready for the offline conversions Secret Setup.

Tips from people who set these up every week

  • iPhone visits from Google Ads often carry gbraid or wbraid instead of gclid: the script keeps those too.
  • Some cookie banners block localStorage until consent: if so, fire this tag on consent like your other marketing tags.

Troubleshooting: questions and answers

The hidden field is empty.

Check the field's name is exactly gclid (lowercase) and the tag fired in Preview. Some form tools put the form in an iframe, where a script on your page can't reach: use that tool's own UTM settings instead.

Official help pages

Let Claude fix the rest of your funnel

Lead Focus is 12 Claude Skills that find the stage of your funnel that's costing you leads, then fix it: ads, landing pages, follow-ups and tracking. One payment, 12 months of updates, and a 14-day refund.

Get Lead Focus · $29.99

Still stuck, or have a question?

Tell us where you got to and what you see. We read every message and reply by email, usually the same working day.