Skip to content
Adrythm

How-to

Save the Google click ID with every form lead

Updated November 21, 2026

1 hour, with a developer

Add hidden fields named gclid, gbraid and wbraid to every form, and a script on every page that stores the ID from the ad's landing address and fills those fields. Keep the latest ad click, let redirects pass the ID through, and test with a made-up ID. Google's sample script saves the gclid only.

Before you start

  • Auto-tagging on in Google Ads. Without it no click ID is added to the address. It is under Admin, Account settings, Auto-tagging.
  • Access to edit every form on the site, and a place in your lead system for three extra fields on each lead.
  • Publish access to Tag Manager, or a developer who can add a script to every page.

Add the hidden fields

Three hidden fields on every form give each lead a place to carry its click ID.

  1. Add three hidden fields to every form on the site: gclid, gbraid and wbraid. Google's guide shows the gclid field; its lead upload guidance asks for GBRAID and WBRAID whenever they are available. Some iPhone and iPad clicks arrive with one of those in place of a GCLID.
  2. Give each hidden field an id as well as a name, and list those ids in the script. Google's sample only fills the field ids written in its gclidFormFields line, so a field it does not list stays empty on every lead.
  3. Make sure the form system saves those fields with each lead and passes them on to wherever leads end up, such as a CRM or the notification email. Google says the GCLID is case sensitive, so store it exactly as it arrived.
  4. If your form tool already records the page address with each entry, keep everything after the ? in it. When the form is on the page the ad landed on, that address carries the click ID even if a hidden field fails.

Store the ID when the visitor lands

A script on every page keeps the click ID from the ad's landing address and fills the hidden fields, since the ID is only in the address of the first page and the form may be sent pages or days later.

  1. Add the script to every page of the site, not only the landing pages, as Google recommends. Google's sample keeps the GCLID in browser storage for 90 days and fills the hidden field when each page loads.
  2. Have the script fill every matching field on the page. Google's sample fills one field per page, so on a page with two forms, such as one in the header and one in the footer, only one of them gets the ID.
  3. Extend it to read gbraid and wbraid the same way, each into its own field. Never fold a gbraid or wbraid into the gclid field. Each is its own identifier, with its own place in a lead upload.
  4. Let a newer ad click replace the stored one. A script that keeps only the first visit sends no click ID for someone who first found the site another way and came back through an ad.
  5. If a form appears after the page has loaded, such as in a pop-up or a second step, have the script fill it when it appears. Google's sample fills fields once, on page load.
  6. In Tag Manager, add the script as a Custom HTML tag on the All Pages trigger, then click Submit and Publish.

Keep the ID through redirects

A quick test with a made-up ID shows whether the click ID survives every redirect to the final landing page.

  1. Open your landing page with ?gclid=test added to the end of its address (use & instead of ? if the address already has a ?). If the site redirects, the address you end on must still show gclid=test. Google says the GCLID has to reach the final landing page.
  2. If the page shows an error instead, the site rejects unknown parameters. Google's instruction is to turn auto-tagging off, have your developer allow arbitrary URL parameters, then turn it back on.

Check it worked

Open a landing page with ?gclid=test-123 at the end of the address (use & instead of ? if the address already has a ?), click through to another page, and send a form. The lead should arrive with test-123 in its gclid field. Repeat with ?wbraid=test-456 and check the wbraid field, then delete both test leads.

After a week of ads, look at the form leads from that week. Most leads you know came from ad clicks should carry an ID. An empty field is not proof a lead came from elsewhere: private browsing in some browsers can remove tracking parameters from the address, and a cookie banner can stop the script storing one for visitors who decline.

What a GCLID is, and what the saved ID is for

The GCLID, short for Google click identifier, is a code Google Ads adds to the landing page address of each ad click when auto-tagging is on. It names that one click, so a lead that keeps it can be matched to the ad, keyword and campaign behind it.

A lead that carries its click ID can be sent back to Google Ads when it becomes a qualified lead or a sale, so bidding learns which clicks produced customers. Google calls the GCLID strongly recommended in those uploads even when enhanced conversions is on.

Why some iPhone clicks carry no GCLID

Since Apple's App Tracking Transparency rules took effect in April 2021, Google no longer sends the GCLID on iOS traffic from a handful of Google apps. Google added the wbraid parameter to measure those clicks. Google says most advertisers need no website change for it, but a form that saves only the gclid has no click ID to keep for those leads.

What six live sites kept from a test click, 2026-11-21

On 2026-11-21 six websites Adrythm runs, five local businesses and its own, were opened in Chrome as a phone with a made-up gclid and wbraid added to the home page address, then again with a new made-up gclid only, then in a new tab with no parameters. After each visit the page was scrolled and left nine seconds so delayed tags could load, and every cookie, localStorage and sessionStorage value holding a test ID was read. Sites are not named, and no form was sent.

None of the six contact pages had a gclid, gbraid or wbraid hidden field. Each site's form is drawn by its own script, and each kept the click ID in browser storage under a key of its own, to send with the lead when the form goes. Hidden fields, as in the first part above, are one way to carry the ID; a script that reads storage at the moment of sending is the other.

Every redirect kept the ID. Each home page was opened through http and through the other www spelling of its host. All 11 redirects that answered ended on an address that still held the test gclid. The twelfth, one site's www spelling, could not be reached from the test machine.

Google's own storage held the gclid and not the wbraid. On the five sites with a Google Ads conversion linker, the _gcl_aw cookie and the _gcl_ls entry in localStorage held the test gclid, and the second click replaced it. With both IDs in the same address, neither held the test wbraid.

All six sites' own stores kept the wbraid, five in the same record as the gclid and one under a key of its own.

The newest click won on three sites, the first click on one. Two replaced the whole record on the second visit, dropping the old wbraid with it. One replaced the gclid while its separate wbraid key kept the first click's value, so a lead from it would carry IDs from two different clicks. One kept the first click for the rest of the visit. The other two stored both clicks, so which one a lead sends depends on their form code.

One site's own store lived only in the tab. It used sessionStorage, so the copy was gone in a new tab, while the _gcl_aw cookie still held the click. A visitor who comes back the next day to fill in the form would send no ID from that store.

The call tracking script kept the first click on all four sites that had one. Its storage still held the first test gclid and wbraid after the second click and in the new tab. That is its own record of the first visit, so it can name a different click from the one the form sends.

Which click ID your site keeps: a path

Open your landing page with ?gclid=test-1&wbraid=test-2 at the end of the address, then open it again with ?gclid=test-3. Open the browser's developer tools, go to Application, look under Local storage, Session storage and Cookies for your site, and stop at the first line that fits.

test-1 is stored and test-3 is not. The script keeps the first click. Change it to overwrite the stored ID whenever a new one arrives, as in the second part above.

test-1 and test-3 are both stored. Read the form code to see which one it sends, and make it the newest.

test-2 sits beside test-3. The wbraid is left from the older click. Clear the gbraid and wbraid whenever a new click ID arrives, so one lead never mixes two clicks.

Nothing survives a new tab. The script uses sessionStorage. Move it to localStorage or a first-party cookie, kept as long as Google's own 90 days.

Only _gcl_aw holds the ID. The form can read the gclid from that cookie, but in the test above it held no wbraid, so keep a store of your own for the wbraid.

Lead and call tracking is one of the things we sell, and it goes in before any ad budget is spent. Jobs like this one are part of that work.

Still have a question this page did not answer?

Ask it on a call. Thirty minutes, a straight answer, and no follow-up sequence if you decide not to work with us.