
How to Capture the Google Ads GCLID in WordPress Forms
When someone clicks one of your Google Ads, Google adds a click ID called gclid to the end of the link. If you save that ID with the form the visitor sends, you’ll always know which leads came from Google Ads, and you can pass it on to your CRM. With the free Ad Tracking add-on in Auto Form Builder, it takes one hidden field and about five minutes. No code needed.
Related video: How to Track Which Ad Brought Each WordPress Form Lead
What is a gclid?
A gclid (Google click identifier) is a long code that Google Ads adds to your page address when auto-tagging is on, like this: yoursite.com/quote/?gclid=Cj0KCQ.... Each ad click gets its own gclid.
The problem is that the gclid only lives in the address bar. As soon as the visitor clicks to another page, it’s gone, and your form never sees it. The Ad Tracking add-on solves this: it saves the gclid in a small cookie on your own site, so a form on any page can pick it up later.
What you need before you start
- A WordPress site with Auto Form Builder and a form, such as a quote request form
- Google Ads with auto-tagging turned on (you can check it in your Google Ads account settings), or just a test link, as shown in Step 3
- About five minutes
Step 1: Activate the Ad Tracking add-on
In your WordPress dashboard, go to Auto Form Builder → Add-Ons, find Ad Tracking and click Activate. Then click Settings on the same card.
The settings page has two options:
- Capture saves ad click IDs and UTM parameters in a cookie named
afb_attr. Keep it ticked. - Cookie lifetime is how many days the values are kept. Choose a number that fits how long your customers usually take to decide.
Below them, a reminder says: “Ask your visitors for consent first where the law requires it.” Click Save Changes if you changed anything.
![]()
Step 2: Add a hidden GCLID field to your form
Open your form in the form builder and add a Text Input field. Then, in Field Properties:
- Set Field Label to
GCLID. Only you see this label, in your entries. - Scroll down and tick Hidden Field. Visitors won’t see the field, but its value is sent with the form.
- In Hidden Value, type
{gclid}, with the curly braces.
You’ll notice the Default Value box shows {gclid} too. That’s expected: leave it as it is. If you clear it, the Hidden Value is cleared as well.
Click Save Form.

Step 3: Test it with a fake gclid
You don’t need to pay for an ad click to test this. Open a private (incognito) window, so you start like a brand-new visitor, and open your form’s page with a made-up gclid at the end of the address:
https://yoursite.com/your-form-page/?gclid=TeSt123abc
If your page address already contains a ?, add &gclid=TeSt123abc instead. Fill in the form and send it.
Now open Auto Form Builder → Submissions and click the new entry. Next to GCLID, you’ll see TeSt123abc. Real ad clicks will show Google’s long code in the same place.

Latest click or first click?
The {gclid} tag always holds the latest visit that came from an ad or a campaign link. Each new ad visit replaces it. Normal visits, without any click ID or UTM parameters, leave it alone.
This matters when you also track UTM parameters. In our test, a visit with only a gclid replaced the latest UTM values too, so UTM Source was empty on that entry, because that visit had no UTM parameters.
If you’d rather keep the very first ad click that brought the visitor, add a second hidden field with the {first_gclid} tag. You can use both and see the first and the latest click on every entry.
Send the gclid to your CRM
Hidden fields put the gclid on your entries in WordPress. To send it to a CRM or another app, use a webhook: the same tags, such as {gclid}, work in webhook JSON templates. Your CRM can then match each lead to the Google Ads click that brought it.
Troubleshooting
- The entry shows
{gclid}as text. The Capture option is turned off on the Ad Tracking page. Tick it and click Save Changes. - The GCLID field is empty. The visit didn’t carry a gclid, or the cookie was cleared. Closing a private window also deletes its cookies, so run the test again in a new private window.
- It stopped working after you edited the field. Check that Hidden Value still says
{gclid}. Clearing Default Value also clears it.
Summary
To capture the Google Ads gclid in a WordPress form, activate the free Ad Tracking add-on, add a Text Input with Hidden Field ticked and {gclid} as its Hidden Value, and test it with a fake ?gclid= link. Every new entry then shows the click ID, even when the visitor sends the form from another page.
Related reading:
FAQ
Is it free?
Yes. The Ad Tracking add-on is built into Auto Form Builder at no cost, like every other add-on.
What about gbraid and wbraid?
Google Ads sometimes sends gbraid or wbraid instead of gclid. The add-on saves those too. Add hidden fields with the {gbraid} and {wbraid} tags if you want them on your entries.
Do I need cookie consent?
It depends on where your visitors are. The values are kept in a first-party cookie, so ask your visitors for consent first where the law requires it.