UTM Parameter Tracking on WordPress: How to Capture Lead Source Data and Keep It

If you are running paid ads and relying on your ad platform’s dashboard to tell you which campaigns are generating leads, you are missing part of the picture. Ad platforms count clicks. UTM parameters let you count what happens after the click: form submissions, phone calls, and ultimately closed deals.

This guide covers how UTM parameter tracking works on WordPress, how to pass UTM data through to your lead records, and how to use that data to make better decisions about where to spend your marketing budget.

What UTM Parameters Are (and Why They Matter)

UTM parameters are small tags you append to a URL. When someone clicks a link with UTM tags, those values land in the URL bar, and your tracking tools can read them. A tagged URL looks like this:

https://example.com/landing-page/?utm_source=google&utm_medium=cpc&utm_campaign=summer-promo

The five standard UTM parameters:

  • utm_source — where the traffic is coming from (google, facebook, email, newsletter)
  • utm_medium — the type of traffic (cpc, organic, social, email)
  • utm_campaign — the specific campaign name (summer-promo, brand-search, retargeting)
  • utm_content — the specific ad or link variant (useful for A/B testing)
  • utm_term — the keyword that triggered the ad (usually auto-populated by Google Ads)

When these values are in the URL, GA4 can attribute the session to the right source. But GA4 only sees the session — it does not see the lead form submission in the context of the original source unless you capture and store the UTM data yourself.

The Core Problem: UTMs Die When Someone Submits a Form

Here is the gap that most WordPress sites have. A visitor arrives from a Google Ads click. Their URL has utm_source=google and utm_campaign=brand-search. They spend 3 minutes on your site, then submit a contact form. That form submission lands in your inbox or CRM with their name, email, and message — but no UTM data. You cannot tell whether this lead came from Google Ads, organic search, or a direct visit.

Multiply this across 50 leads a month and you have a marketing team making budget decisions based on incomplete information.

The solution is a two-step process: capture the UTM values when someone first lands, and carry them through to the form submission.

How to Capture UTM Parameters in WordPress

Step 1: Store UTMs in a first-party cookie on landing

When a visitor arrives with UTM parameters in the URL, a small JavaScript snippet reads those values and saves them in a first-party cookie. That cookie persists for 30 days (or whatever window you set), so even if the visitor leaves and comes back without UTMs in the URL, you still have the original attribution data.

The script runs on page load, checks for UTM values in the URL, and writes them to cookies only if they are present (so a returning visitor’s original attribution is not overwritten by a direct visit).

// Capture UTMs on first touch, store in cookies for 30 days
(function() {
  var params = new URLSearchParams(window.location.search);
  var utms = ['utm_source','utm_medium','utm_campaign','utm_content','utm_term'];
  utms.forEach(function(key) {
    var val = params.get(key);
    if (val) {
      document.cookie = key + '=' + encodeURIComponent(val) + '; path=/; max-age=2592000; SameSite=Lax';
    }
  });
})();

Add this to your WordPress site via a plugin like WPCode, through your theme’s functions.php, or through Google Tag Manager as a Custom HTML tag triggered on All Pages.

Step 2: Pull UTM cookies into hidden form fields

Your contact form (whether it is Gravity Forms, WPForms, Contact Form 7, or another plugin) should have hidden fields that read the UTM cookie values and include them in the submission. When someone submits the form, the UTM values travel with the lead data.

Hidden field setup (in Gravity Forms as an example): add a Hidden field for each UTM parameter and set its default value to a JavaScript snippet that reads the corresponding cookie. Most form plugins support dynamic default values via a parameter name or a short code.

The pattern: each hidden field reads its cookie value on page load and populates automatically. The user never sees these fields. The form submission includes both the visible data the user entered and the UTM attribution data you captured in the background.

Passing UTM Data to Your CRM or Email Platform

Once UTM values are in your form submission, they need to land somewhere useful. A few options:

  • Email notification: the simplest path — your form sends a notification email that includes all field values. The UTM fields show up alongside name, email, and message. Works immediately with no integration.
  • CRM via Zapier or native integration: map the UTM hidden fields to custom fields in your CRM. Now each deal record shows source, medium, and campaign. When a deal closes, you can trace it back to the originating campaign.
  • Google Sheet as a lead log: route form submissions to a sheet with columns for all UTM parameters plus timestamp, name, email, and message. A simple way to see lead source distribution without a CRM.

What to Do With UTM Data Once You Have It

UTM data becomes valuable when you connect it to outcomes, not just volume. A few questions it lets you answer:

  • Which campaigns generate the most leads? Basic source/medium/campaign breakdown. Google Ads vs. organic vs. Facebook vs. email.
  • Which campaigns close at the highest rate? If you track deal outcomes in a CRM, you can pull close rate by utm_campaign. A campaign generating 20 leads at 5% close rate is worth less than one generating 8 leads at 40% close rate.
  • Which keywords drive qualified leads vs. browsers? utm_term populated from Google Ads auto-tagging tells you exactly which search query preceded each lead. You can pause terms that generate volume but not closed business.
  • Which ad variants convert better? utm_content lets you tag individual ads or email links differently. If Ad A and Ad B send equal traffic but Ad A generates twice the form submissions, that is a clear signal.

gclid vs. UTM: Which Should You Use?

Google Ads appends a gclid (Google Click ID) to URLs automatically when auto-tagging is enabled. This is separate from UTM parameters and is used for Google’s internal attribution. You should use both.

  • UTM parameters give you source/medium/campaign data that works across platforms and integrates with GA4, your CRM, and any reporting tool you use.
  • gclid enables offline conversion upload to Google Ads — where you send lead outcome data back to Google so its algorithm can optimize toward closed deals, not just form submissions.

The right setup captures both: UTMs go into cookies and then form fields for your own reporting, while gclid is captured separately for offline conversion sync back to Google Ads.

Common WordPress Implementation Pitfalls

  • UTMs lost on redirect: if your landing page URL redirects (www to non-www, HTTP to HTTPS, or a tracking redirect), UTM parameters can be stripped. Audit your redirect chain and make sure parameters pass through.
  • Form caching stripping values: some caching plugins prevent JavaScript from running correctly on form pages, which means hidden fields do not populate. Add form pages to your cache exclusion list.
  • Cookie consent blocking the script: if you have a GDPR consent banner that delays non-essential scripts, UTM capture may not fire until after the user accepts. For most service businesses in the US this is not a live issue, but it is worth knowing.
  • Session-scoped storage losing first touch: using sessionStorage instead of cookies means attribution is lost if the user closes their browser and returns later. Use cookies with a 30-day window for first-touch attribution.
  • Overwriting first touch on return visits: your capture script should check whether a UTM cookie already exists before overwriting. If someone clicks an organic result in week 2, you do not want to overwrite the paid ad click from week 1 that actually drove the engagement.

UTM Tracking as Part of a Larger Attribution Stack

UTM tracking solves the first-party data capture problem: you own the lead source data, it lives in your CRM, and it survives the gap between ad click and form submission. But it is one layer of a full attribution stack.

  • UTMs tell you source, medium, and campaign at the session level
  • Offline conversion upload connects closed deals back to campaigns in Google and Meta
  • Phone call tracking via DNI (dynamic number insertion) captures attribution for callers who never submit a form
  • Revenue attribution pulls closed deal values back into your reporting so you see revenue by source, not just lead count

For WordPress businesses running paid search and wanting a turnkey version of this stack — UTM capture, form submission tracking, offline conversion sync, and closed-loop revenue reporting — Sales Provenance is built to handle all of it natively, without requiring a data engineer or a CRM dependency.

Related reading: Google Ads conversion tracking on WordPress — how to set up website conversions, capture gclid, and upload offline conversions. And closed-loop reporting for WordPress — connecting ad spend to closed deal value.