How to track UTM parameters and gclid in WPForms

WPForms makes it easy to build a contact or quote form, and every entry lands in your inbox. What an entry does not show is how the person found your website. If you pay for Google Ads, Meta ads or a newsletter, you need that to know which of them actually brings enquiries.

Video: track UTM parameters and gclid in WPForms
Watch the 90-second video on YouTube

This guide shows how to save the UTM parameters and the Google click ID (gclid) with each WPForms entry, first by hand and then automatically.

What the source of a lead looks like

When someone clicks an ad or a link in your newsletter, the address of the page they arrive on usually carries tracking parameters:

https://example.com/?utm_source=facebook&utm_medium=paid_social&utm_campaign=spring-offer

utm_source, utm_medium, utm_campaign, utm_term and utm_content are set by you in your ads and links. Google Ads adds gclid to every click when auto-tagging is on, and Microsoft Advertising adds msclkid. Visitors from an ordinary search or from social posts without such a link arrive without parameters; for them, only the referrer says where they came from.

Method 1: hidden fields with the query_var smart tag

WPForms has a Hidden Field under Fancy Fields, and its default value can use smart tags. The smart tag {query_var key="..."} reads a parameter from the address of the current page.

  1. Open your form in the WPForms builder.
  2. Add a Hidden Field and set its label to utm_source.
  3. Under Advanced → Default Value, enter {query_var key="utm_source"}.
  4. Repeat for utm_medium, utm_campaign, utm_term and gclid.
  5. Save the form.

The values are now stored with each entry and can be added to the notification email under Settings → Notifications, with Show Smart Tags next to the message, or simply with {all_fields}.

Test it by opening the page with the form through an address such as https://example.com/contact/?utm_source=test&utm_campaign=check and sending an entry.

Where this method falls short

{query_var} only reads the address of the page that shows the form, at the moment the form is loaded. That works when the form sits on the landing page of your ad. It does not work when:

  • the visitor arrives on one page and sends the form from another, which is the usual case for a contact page;
  • the visitor clicks your ad today and comes back directly next week to write to you;
  • the visitor found you through a search engine, a social network or another website, without UTM parameters at all;
  • a caching plugin serves the same cached page to everyone, which can keep the default value of the first visitor in the HTML.

To cover these cases you need something that remembers the source for the whole visit, and across visits, and reads the referrer as well.

Method 2: automatic, with Dealroot

Dealroot is a free plugin that follows each visitor from the first visit to the enquiry and saves every WPForms entry as a lead with its source. You do not need hidden fields for that.

  1. Install and activate Dealroot from Plugins → Add Plugin.
  2. Open Leads → Forms and click Scan site. Your WPForms forms are listed and ticked.
  3. Send a test entry through https://your-site.com/?utm_source=test&utm_medium=cpc and open Leads → All leads.

Each lead shows the channel, such as paid search, organic search, social, email or referral, and the source, campaign, keyword, click ID and landing page of the first and the latest visit, with the pages the person saw before writing.

The source in the WPForms notification email

Turn on Leads → Settings → Forms → Source in your forms, and the channel, source, campaign and landing page are added below the notification emails of all your forms. Emails to the visitor stay as they are. To place it yourself, Dealroot adds a smart tag to WPForms: {dealroot_attribution}.

Hidden fields filled on the server

If you send WPForms entries on to a CRM, a spreadsheet or Zapier, keep hidden fields labelled utm_source, utm_medium, utm_campaign, utm_term, gclid or dealroot_channel, and leave their default value empty. Dealroot fills them on the server when the form is sent, from what it remembered about the visitor, so cached pages and later visits no longer matter. In WPForms, the label of the field counts.

Summary

{query_var} in a hidden field is a quick fix for forms on ad landing pages. If your visitors read a few pages, come back later or find you without ads, let a plugin follow the whole visit. Dealroot saves the source with every WPForms entry and shows in a report which channel and campaign brought how many enquiries, and, once you mark leads as won, how much revenue.

See which ads pay for themselves.

Install the free plugin today. When you want your ads to learn from your sales, upgrade in a minute and keep every lead you collected.

Choose a plan Get the free plugin