Skip to content

How to Track the Source of Leads in WordPress Forms

When a WordPress form arrives with only a name and email, the marketing channel behind that lead disappears. This guide shows how to attach source data to every submission so you can tell whether a lead came from organic search, paid search, paid social, or another channel — and see the campaign, ad, keyword, and landing page where available.

The four-step setup sequence

The workflow has four stages: install the source-tracking script, add hidden fields to the form, let the script populate those fields, and pass the captured values to the places where you review or store leads. Each stage has a distinct failure mode, so check them in order rather than treating a blank source field as one generic problem.

Step 1: Install the script and add hidden fields

The tracking script is a small piece of code added to the website. On arrival, it determines where the visitor came from, stores that information in a cookie, and passes it through when a form is submitted. After installing the code, add hidden fields to each form. The field names used in the original setup are: Channel, Channel Drilldown 1, Channel Drilldown 2, Channel Drilldown 3, and Channel Drilldown 4. Most WordPress form builders support hidden fields, including Gravity Forms, WPForms, Contact Form 7, and Formidable Forms. Builder-specific instructions, with screenshots, are available for each of these tools.

Step 2: The script fills the hidden fields

When a visitor completes a form, the script writes source information into the hidden fields. An organic Google search, for example, produces a channel value of Organic Search plus the search engine name. A Google Ads visit produces Paid Search plus campaign, ad, and keyword detail where those parameters are present. The values depend on the UTM parameters behind the ad, so a missing or malformed UTM tag can leave drilldown fields blank even when the channel is correctly identified.

Step 3: The form builder captures the values

On submission, the form builder stores the hidden-field values alongside what the lead typed — name, email, phone, and any other visible fields. At this point the source data exists inside the form tool. If the entries table shows the visible fields but not the source fields, the problem is usually in step 1 or step 2: the hidden fields were not added, their names do not match, or the script did not run on the page containing the form.

Step 4: Send the data where you will use it

Captured values can be used in four practical destinations. Review them in the form tool's Entries or Submissions table. Include them in notification emails so each lead's origin is visible from your inbox. Send them to a CRM such as Salesforce, HubSpot, or Pipedrive through native integrations or a connector like Zapier, then build reports on top. Or send them to a spreadsheet for reporting. Choose destinations based on who acts on the lead and which system owns the reporting; sending to every destination without a clear owner tends to create conflicting records.

What data gets captured

Two families of data are captured: marketing channel data and landing page data. Channel data identifies the broad source and then drills down through successive levels. Landing page data records the first page the lead saw and the category of that page, such as Blog. Together they let you compare sections of the site as a whole and then inspect individual posts.

Worked example: reading the drilldown values

Suppose a lead arrives from a Google Ads click. The captured values might read: Channel = Paid Search; Channel Drilldown 1 = Google; Channel Drilldown 2 = Brand Campaign; Channel Drilldown 3 = Free quote ad. A lead from an organic Google search might instead read: Channel = Organic Search; Channel Drilldown 1 = Google; Channel Drilldown 2 = www.google.com (or whichever Google domain the visitor used); Channel Drilldown 3 = the keyword they used to find the site, where available. The same field positions carry different meaning depending on the channel, so reports should group by channel before interpreting drilldown levels. A blank Drilldown 3 on an organic lead is not necessarily a tracking failure; keyword data is not always available.

Three different failures that look alike

A blank source field can come from three separate causes. First, the hidden fields may be missing from the form or named differently from the script's expected names. Second, the script may be absent from the page, blocked, or unable to read the referral or UTM data. Third, the form tool may be capturing the values correctly but the CRM integration may not be mapping those fields to CRM properties. Diagnose in that order: inspect the form's hidden fields, then the form entry, then the CRM record. Fixing the CRM mapping will not help if the entry itself is empty.

Three reports worth building

Once source data reaches a CRM or reporting tool, three report shapes are useful. A leads-by-channel report shows monthly lead volume by channel and helps compare where leads actually come from against where budget goes. A customers-by-Google-Ads-campaign report separates campaigns that generate customers from campaigns that generate only clicks and visits. A revenue-by-Facebook-ad-network report breaks revenue down by network — Facebook, Instagram, Messenger, WhatsApp — and, combined with spend data from Facebook Ads, supports a return-on-investment comparison per network.

Pre-launch checklist

Before relying on the data, confirm each item: the tracking script loads on every page that contains a form; each form has all five hidden fields with matching names; a test submission from a tagged URL produces the expected channel and drilldown values in the form tool's entries table; notification emails include the source fields; and the CRM or spreadsheet receives the same values with correct field mapping. Repeat the test after any form-builder or theme update, since hidden fields can be lost when a form is rebuilt.

Frequently asked questions

Which WordPress form builders support hidden source fields?

Most do. Gravity Forms, WPForms, Contact Form 7, and Formidable Forms are common examples that make hidden fields easy to add. The fields to create are Channel, Channel Drilldown 1, Channel Drilldown 2, Channel Drilldown 3, and Channel Drilldown 4.

Why is the source field blank on some submissions?

Check the hidden fields first, then the page script, then the CRM mapping. A blank value can come from a missing or misnamed hidden field, a script that did not run, or a CRM integration that did not map the captured value.

Does the drilldown detail depend on UTM parameters?

Yes for paid campaigns. The captured drilldown values depend on the UTM parameters behind the ad, so incomplete tagging can leave campaign, ad, or keyword fields empty even when the channel is identified correctly.

Why is the organic keyword sometimes missing?

Keyword data for organic search is not always available. The drilldown may show the search engine domain without a keyword, and that is expected rather than a tracking failure.