WPForms UTM Tracking: Capture Lead Source Data in Every Form Entry

WPForms powers over six million WordPress sites. It’s fast to set up, beginner-friendly, and integrates with dozens of CRMs and email marketing tools. But there’s one thing WPForms doesn’t do out of the box: tell you where your leads came from.

You’re running Google Ads, Facebook campaigns, LinkedIn promotions, and email blasts. Leads arrive through your WPForms — but every form entry looks the same. Name, email, message. No source, no campaign, no indication of which ad or channel brought the visitor to your site.

This guide fixes that. You’ll learn how to capture UTM parameters, click IDs (gclid, fbclid, msclkid, li_fat_id, ttclid), and the referrer URL in WPForms — so every form entry carries complete attribution data. We’ll cover the native smart tag method, explain why it breaks in practice, show the JavaScript and cookie approach that works reliably, and introduce an automated solution that eliminates the setup entirely.

What Attribution Data Should WPForms Capture?

Before configuring anything, understand the four types of data that a form entry should include:

Data TypeWhat It Tells YouExample
UTM parametersWhich campaign, source, medium, keyword, and ad creative sent the visitorutm_source=google, utm_medium=cpc, utm_campaign=spring-promo
Click IDsA unique identifier linking the click to a specific ad platform for offline conversion trackinggclid=Cjw…, fbclid=IwAR3…, msclkid=abc123
Referrer URLThe website or search engine the visitor came from before landing on your sitehttps://www.google.com/
Landing pageThe first page on your site the visitor saw — confirms which campaign URL they arrived on/services/?utm_source=google&utm_medium=cpc

Together, these four data points give you a complete attribution trail. UTM parameters reveal the campaign context. Click IDs let you send conversions back to ad platforms. The referrer identifies organic and social traffic. And the landing page confirms the visitor’s entry point.

WPForms captures none of this by default. But it does offer hidden fields and smart tags that can pull query string values from the URL. Let’s start there.

Method 1: Hidden Fields with Smart Tags (the Native Approach)

WPForms supports hidden fields with a built-in smart tag called {query_var} that reads values from the URL’s query string. Here’s how to set it up for UTM tracking:

Important: Hidden fields are not available in WPForms Lite (the free version). You’ll need at least the Basic paid plan.

Step 1: Add Hidden Fields

Open your form in the WPForms builder. In the left panel under “Fancy Fields,” drag a Hidden Field onto your form. Add one hidden field for each parameter you want to capture. At minimum, create fields for the five standard UTM parameters.

Label each field clearly — for example, “UTM Source,” “UTM Medium,” “UTM Campaign.”

Step 2: Configure Smart Tags

Click on each hidden field to open its Field Options. Go to the Advanced tab and find the Default Value setting. Click “Show Smart Tags” and select Query String Variable. This inserts {query_var key=""} into the Default Value box.

Between the quotes, enter the UTM parameter name. Repeat for each field:

Field LabelDefault Value (Smart Tag)
UTM Source{query_var key="utm_source"}
UTM Medium{query_var key="utm_medium"}
UTM Campaign{query_var key="utm_campaign"}
UTM Term{query_var key="utm_term"}
UTM Content{query_var key="utm_content"}

Step 3: Include Fields in Notification Emails

Go to Settings > Notifications in the form builder. By default, the {all_fields} smart tag is included in the email body, which will output hidden field values. If you’ve customised the template, add individual smart tags for each hidden field (e.g., {field_id="15"} — the number matches the field ID shown in the builder).

Step 4: Test It

Add UTM parameters to your form page URL and submit a test entry:

https://yoursite.com/contact/?utm_source=google&utm_medium=cpc&utm_campaign=spring-sale

Check the entry in WPForms > Entries. Your hidden fields should show the UTM values from the URL.

This works — but only when the visitor is on the exact page that has UTM parameters in the URL. In practice, it breaks in several common scenarios.

Why Smart Tags Break for UTM Tracking (and How to Fix Each Issue)

The {query_var} smart tag is convenient but fragile for attribution tracking. Here are the most common reasons it fails.

1. UTM Parameters Disappear on Page Navigation

This is the most fundamental problem — and it’s not a WPForms bug, it’s how URLs work. UTM parameters only exist in the URL of the landing page. When a visitor clicks to any other page on your site, those parameters vanish.

Example: A visitor clicks your Google Ad and lands on /services/?utm_source=google&utm_medium=cpc. They browse your site, then navigate to /contact/ to fill out your form. The /contact/ URL has no query parameters. The {query_var} smart tag finds nothing. Your form entry shows blank UTM fields.

This happens on virtually every website where the form is on a different page than the landing page.

Fix: Store UTM values in cookies when the visitor first arrives, then populate form fields from cookies rather than the URL. We’ll cover the full implementation below.

2. Page Caching Serves Stale Values

If your site uses caching (WP Rocket, W3 Total Cache, LiteSpeed, Cloudflare, or managed hosting like WP Engine or Kinsta), the cached page may serve the same pre-rendered HTML to every visitor. The {query_var} smart tag is processed server-side when the page renders. On a cached page, it either returns empty values or — worse — returns another visitor’s UTM data.

Fix: Exclude the form page from your cache, or switch to the client-side cookie approach (Method 2), which isn’t affected by server-side caching.

3. WPForms Lite Doesn’t Support Hidden Fields

The free version of WPForms (WPForms Lite) doesn’t include the Hidden Field type. You need at least the Basic paid plan to add hidden fields to your forms. If you’re on the free version, you can’t use the native smart tag approach for UTM tracking at all.

Fix: Upgrade to a paid WPForms plan, or use a plugin like LeadSourcePro that doesn’t require hidden fields.

4. Prefill by URL Uses a Different Format

WPForms also offers a “Prefill by URL” feature (Settings > General > Advanced), but it uses a different query string format: wpf{formID}_{fieldID}=value. This means a URL like ?utm_source=google won’t work with Prefill by URL — you’d need ?wpf20_15=google (where 20 is the form ID and 15 is the field ID). Since ad platforms send standard UTM parameter names, Prefill by URL isn’t useful for UTM tracking.

Fix: Use the {query_var} smart tag method instead of Prefill by URL for UTM parameters. Or use the cookie-based approach.

Method 2: JavaScript and Cookies (the Reliable Approach)

The smart tag method reads from the URL at page-load time. A more reliable approach stores UTM values in the visitor’s browser cookies when they first arrive, then populates form fields from those cookies — regardless of which page the form is on.

Part 1: Capture and Store UTM Parameters in Cookies

Add this JavaScript to your site (via your theme’s header, a custom plugin, or a code snippets plugin like WPCode). It runs on every page and stores UTM parameters and click IDs as first-party cookies for 90 days:

<script>
(function() {
  var params = ['utm_source', 'utm_medium', 'utm_campaign',
                'utm_term', 'utm_content', 'gclid', 'fbclid',
                'msclkid', 'li_fat_id', 'ttclid'];
  var search = new URLSearchParams(window.location.search);
  var dominated = false;

  params.forEach(function(p) {
    if (search.has(p)) dominated = true;
  });

  if (dominated) {
    params.forEach(function(p) {
      var val = search.get(p) || '';
      document.cookie = p + '=' + encodeURIComponent(val) +
        ';path=/;max-age=7776000;SameSite=Lax';
    });
  }

  if (!getCookie('landing_page')) {
    document.cookie = 'landing_page=' +
      encodeURIComponent(window.location.href) +
      ';path=/;max-age=7776000;SameSite=Lax';
    document.cookie = 'referrer_url=' +
      encodeURIComponent(document.referrer || '(direct)') +
      ';path=/;max-age=7776000;SameSite=Lax';
  }

  function getCookie(name) {
    var match = document.cookie.match(
      new RegExp('(^| )' + name + '=([^;]+)')
    );
    return match ? decodeURIComponent(match[2]) : '';
  }
})();
</script>

Part 2: Populate WPForms Hidden Fields from Cookies

Add this JavaScript below the cookie-capture script. It reads cookie values and injects them into WPForms hidden fields on page load. The script targets hidden fields by their CSS class (WPForms assigns a class based on the field ID):

<script>
document.addEventListener('DOMContentLoaded', function() {
  var fieldMap = {
    'utm_source': 'UTM Source',
    'utm_medium': 'UTM Medium',
    'utm_campaign': 'UTM Campaign',
    'utm_term': 'UTM Term',
    'utm_content': 'UTM Content',
    'gclid': 'GCLID',
    'fbclid': 'FBCLID',
    'msclkid': 'MSCLKID',
    'li_fat_id': 'LinkedIn Click ID',
    'ttclid': 'TikTok Click ID',
    'landing_page': 'Landing Page',
    'referrer_url': 'Referrer URL'
  };

  function getCookie(name) {
    var match = document.cookie.match(
      new RegExp('(^| )' + name + '=([^;]+)')
    );
    return match ? decodeURIComponent(match[2]) : '';
  }

  // Find WPForms hidden fields by label and set values
  var inputs = document.querySelectorAll(
    '.wpforms-field-hidden input[type="hidden"]'
  );

  inputs.forEach(function(input) {
    var label = input.closest('.wpforms-field-hidden')
      ?.querySelector('.wpforms-field-label')?.textContent?.trim();
    for (var param in fieldMap) {
      if (label === fieldMap[param]) {
        var val = getCookie(param);
        if (val) input.value = val;
      }
    }
  });
});
</script>

Important: The field labels in fieldMap must match the labels you give your hidden fields in WPForms exactly (including capitalisation). Adjust them if you use different labels.

Part 3: Configure the Hidden Fields

In the WPForms builder, add a Hidden field for each parameter. Label them to match the fieldMap above:

Field LabelData Captured
UTM SourceTraffic source (google, facebook, linkedin)
UTM MediumMarketing medium (cpc, email, social)
UTM CampaignCampaign name
UTM TermPaid search keyword
UTM ContentAd variation identifier
GCLIDGoogle Ads click ID
FBCLIDMeta/Facebook click ID
MSCLKIDMicrosoft Ads click ID
LinkedIn Click IDLinkedIn Ads click ID (li_fat_id)
TikTok Click IDTikTok Ads click ID (ttclid)
Landing PageFirst page URL the visitor saw
Referrer URLExternal site that sent the visitor

Part 4: Test the Full Flow

Open an incognito window. Visit your site with UTM parameters:

https://yoursite.com/services/?utm_source=google&utm_medium=cpc&utm_campaign=spring-sale&gclid=test123

Navigate to a different page — your contact page — and submit the form. Check the entry in WPForms > Entries. The UTM values and gclid from the original landing page should appear in the hidden fields.

Tracking Which Ad Brought Each Submission

To know exactly which ad generated a lead, you need to capture click IDs — the unique identifiers that ad platforms append to your URL when someone clicks an ad.

Ad PlatformClick ID ParameterHow It’s Added
Google AdsgclidAuto-tagging (enabled by default)
Meta (Facebook/Instagram)fbclidAutomatic on all ad clicks
Microsoft AdvertisingmsclkidAuto-tagging (enabled by default)
LinkedIn Adsli_fat_idRequires enabling click ID tracking in campaign settings
TikTok AdsttclidAutomatic when TikTok Pixel is installed

The JavaScript snippet above already captures all five click IDs. Click IDs matter because they link a specific form submission to a specific ad click — enabling offline conversion tracking. You can feed this data back to Google Ads, Meta, or Microsoft Advertising so their algorithms optimise for leads that become customers, not just clicks.

For deeper coverage of how each click ID works, see our guides on gclid tracking, fbclid tracking, and Microsoft, LinkedIn, and TikTok click IDs.

Capturing the Referrer URL in WPForms

Not all traffic arrives with UTM parameters. Organic search, social referrals, and links from other websites don’t carry UTM tags — but the referrer URL tells you where they came from.

WPForms provides a built-in smart tag for this: {url_referer}. You can set it as the Default Value of a hidden field.

The problem: The {url_referer} smart tag captures the last page URL — not the original external referrer. If a visitor arrives from Google, browses three pages on your site, then submits your form, the smart tag will show your own internal page (e.g., /about/) rather than https://www.google.com/. This makes it useless for attribution.

The JavaScript snippet in Method 2 handles this correctly. It captures document.referrer on the visitor’s first page load and stores it in a cookie. Since it only writes the referrer cookie on the first visit, it preserves the original external referrer — giving you the actual source rather than an internal page URL.

What Your Form Entries Should Look Like

With attribution tracking configured, here’s an example of what a WPForms entry looks like with full lead source data:

FieldValue
NameJames Okoro
Emailjames@example.com
Phone021 555 9876
MessageWe’re looking for a partner to handle our paid campaigns
UTM Sourcelinkedin
UTM Mediumpaid-social
UTM Campaignagency-decision-makers
UTM Contenttestimonial-ad-v2
LinkedIn Click IDli_fat_id=abc123xyz
Referrer URLhttps://www.linkedin.com/
Landing Page/case-studies/?utm_source=linkedin&utm_medium=paid-social

Now you know that James came from a LinkedIn Ads campaign targeting agency decision-makers, saw the testimonial ad variation, and landed on your case studies page. You have the LinkedIn click ID to track the conversion back to the specific campaign. That’s lead-level attribution — something Google Analytics cannot provide.

Setting Up Your Ads with UTM Parameters

Your ad URLs need to include UTM parameters for any of this to work. Here’s how to tag campaigns on each major platform:

Google Ads

Google auto-tags with gclid by default. Add UTM parameters via a tracking template at the campaign or account level:

{lpurl}?utm_source=google&utm_medium=cpc&utm_campaign={campaignname}&utm_term={keyword}&utm_content={creative}

Meta (Facebook/Instagram) Ads

Edit the URL Parameters field at the ad level in Ads Manager:

utm_source=facebook&utm_medium=paid-social&utm_campaign={{campaign.name}}&utm_content={{ad.name}}

Microsoft Advertising

Microsoft auto-tags with msclkid. Add UTM parameters via the tracking template:

{lpurl}?utm_source=bing&utm_medium=cpc&utm_campaign={CampaignName}&utm_term={QueryString}

LinkedIn Ads

Add UTM parameters in the Destination URL field:

https://yoursite.com/landing-page/?utm_source=linkedin&utm_medium=paid-social&utm_campaign=your-campaign-name

Enable the LinkedIn Insight Tag and click ID tracking to capture li_fat_id.

TikTok Ads

Add UTM parameters to your destination URL in TikTok Ads Manager:

https://yoursite.com/landing-page/?utm_source=tiktok&utm_medium=paid-social&utm_campaign=__CAMPAIGN_NAME__

TikTok appends ttclid automatically when the TikTok Pixel is installed.

Method 3: Automatic Tracking with LeadSourcePro

The manual methods work, but they require maintaining JavaScript code, hidden field configuration on every form, and careful label matching. If any piece breaks — a theme update removes your scripts, a new form is created without hidden fields, or labels get changed — your attribution data silently stops flowing.

LeadSourcePro eliminates all of that. It’s a WordPress plugin that captures UTM parameters, click IDs (gclid, fbclid, msclkid, li_fat_id, ttclid), the referrer URL, and the landing page automatically — no hidden fields, no JavaScript, no configuration.

Here’s how it works:

  1. Install and activate the plugin. That’s the entire setup.
  2. LeadSourcePro captures attribution data automatically on every page load and stores it using first-party cookies.
  3. When a visitor submits any WPForm, LeadSourcePro attaches the attribution data to the entry. No hidden fields needed.
  4. View the data in WPForms entries, notification emails, or export it to your CRM.

LeadSourcePro works with WPForms and eight other form plugins (including Contact Form 7, Gravity Forms, Ninja Forms, Elementor Forms, Formidable Forms, Fluent Forms, WS Form, and HubSpot Forms). It handles caching, persists data across pages, and captures both first-touch and last-touch attribution.

Comparing the Three Methods

FeatureNative Smart TagsJavaScript + CookiesLeadSourcePro
UTM parametersYes (same page only)Yes (all pages)Yes (all pages)
Click IDs (gclid, fbclid, etc.)Manual per-ID setupYes (with code)Yes (automatic)
Referrer URLLast page only ({url_referer})Original referrer (with cookies)Original referrer (automatic)
Landing page URLNoYes (with cookies)Yes (automatic)
Works with page cachingNoYesYes
Persists across page navigationNoYesYes
Hidden fields requiredYes (paid plan only)Yes (paid plan only)No
Code requiredNoYes (JS)No
Works with WPForms LiteNoNoYes
Maintenance requiredLow (but fragile)Medium (code updates)None

Setup Checklist

  • Add UTM parameters to all ad campaign URLs (Google Ads, Meta, Microsoft, LinkedIn, TikTok)
  • Enable auto-tagging for click IDs on each ad platform
  • Add hidden fields to your WPForms with matching labels (if using Method 1 or 2)
  • Install the cookie-capture JavaScript (Method 2) or LeadSourcePro (Method 3)
  • Update notification email templates to include hidden field smart tags
  • Test in an incognito window — navigate from a UTM-tagged URL to your form page and confirm the data appears in the entry
  • If using hidden fields with UTM parameters, verify your caching plugin isn’t interfering

Frequently Asked Questions

Can I capture UTM parameters with WPForms Lite (the free version)?

Not with Methods 1 or 2, because WPForms Lite doesn’t support hidden fields. LeadSourcePro (Method 3) works with WPForms Lite because it attaches attribution data directly to form entries without requiring hidden fields.

Why are my WPForms hidden fields showing blank UTM values?

The two most common causes: (1) The visitor navigated away from the landing page before reaching the form, so the UTM parameters are no longer in the URL. (2) Page caching is serving a static version of the page that doesn’t process the smart tags. Switch to the cookie-based approach (Method 2 or 3) to solve both problems.

Do I need to add hidden fields to every WPForm on my site?

With Methods 1 and 2, yes — every form needs its own set of hidden fields. With LeadSourcePro (Method 3), no — the plugin attaches attribution data to all form entries automatically.

Can I track organic search leads (no UTM parameters) in WPForms?

Yes — the referrer URL captures this. When someone arrives from Google organic search, the referrer shows https://www.google.com/. Combined with the landing page, you can identify organic traffic without UTM tags. See our guide on tracking lead sources in WordPress forms for the full picture.

What’s the difference between WPForms’ User Journey addon and UTM tracking?

The User Journey addon shows which pages a visitor viewed before submitting the form — it tracks on-site behaviour. UTM tracking shows where the visitor came from before arriving at your site — the ad, campaign, channel, or referring website. They answer different questions. UTM tracking tells you which marketing spend drove the lead. User Journey tells you how they navigated your site after arriving.

Stop losing lead source data from WPForms

LeadSourcePro captures UTM parameters, click IDs, referrer URL, and landing page automatically on every WPForms submission — no hidden fields, no code, no paid plan required. Install LeadSourcePro and see where your leads are really coming from.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *