WordPress 8 min read

WordPress Lead Tracking: How to See Which Marketing Channels Drive Form Submissions

SourceStream Team ·

WordPress powers a massive share of business websites, and most of those sites use form plugins to capture leads. Contact Form 7, Gravity Forms, WPForms, Ninja Forms, Elementor Forms, and dozens more. These plugins do an excellent job of collecting names, emails, and phone numbers, but they all share the same blind spot: they do not tell you where the lead came from.

A form submission arrives in your inbox. You know who submitted it and what they said. But which marketing channel drove them to your site? Which campaign? Which page did they land on? Without this data, every WordPress lead is a mystery.

This guide shows you how to add attribution tracking to any WordPress form plugin, so every lead comes with full source data attached.

Why WordPress Form Plugins Miss Lead Source Data

Form plugins are designed to collect information that the visitor explicitly provides, fields they fill out. Lead source data is different because it comes from the visitor's browsing context: the URL they arrived from, the UTM parameters in the link they clicked, the referrer header sent by their browser.

This contextual data is available in the browser when the visitor arrives, but it disappears as they navigate your site. By the time they reach your contact form, the original URL with its UTM parameters is long gone from the address bar. Form plugins have no mechanism to capture this information automatically.

That is where attribution tracking scripts bridge the gap.

The Solution: Hidden Fields + Attribution Script

The approach works in three steps:

  1. A JavaScript attribution script captures the visitor's source data (UTMs, referrer, landing page, ad click IDs) when they arrive and stores it in first-party cookies.
  2. Hidden fields added to your WordPress forms serve as containers for this data.
  3. The script populates the hidden fields with the stored attribution data just before form submission.

The result: every form submission includes invisible but complete attribution data alongside the lead's visible information.

Setup Guide for Popular WordPress Form Plugins

Contact Form 7

Contact Form 7 is the most widely used WordPress form plugin. Adding hidden fields is straightforward using its built-in hidden field tag.

In your form editor, add hidden fields after your existing fields:

[hidden sp_source class:sp_source ""]
[hidden sp_medium class:sp_medium ""]
[hidden sp_campaign class:sp_campaign ""]
[hidden sp_channel class:sp_channel ""]
[hidden sp_landing_page class:sp_landing_page ""]
[hidden sp_referrer class:sp_referrer ""]

In your Mail tab, add the corresponding mail tags to include the data in notification emails:

Source: [sp_source]
Medium: [sp_medium]
Campaign: [sp_campaign]
Channel: [sp_channel]
Landing Page: [sp_landing_page]

If you are using a CRM integration plugin like HubSpot for WordPress or WP Fusion, map these hidden fields to the corresponding CRM properties.

Gravity Forms

Gravity Forms has a dedicated Hidden Field type in the form editor.

  1. Open your form in the Gravity Forms editor
  2. Under Standard Fields, drag a "Hidden" field into your form
  3. Click the field and set the Label (e.g., "Attribution Source")
  4. In the Advanced tab, set the CSS Class to sp_source
  5. Repeat for each attribution data point (medium, campaign, channel, landing page, referrer)

Gravity Forms hidden fields work seamlessly with its CRM add-ons and Zapier integration, so the attribution data flows wherever your form data goes.

WPForms

WPForms (Lite and Pro) supports hidden fields:

  1. Open your form in the WPForms builder
  2. Drag a "Hidden Field" from the Fancy Fields section
  3. Set the field name and add a CSS class matching the attribution field name
  4. Repeat for each attribution field

Ninja Forms

Ninja Forms supports hidden fields through its form builder:

  1. Open the form editor
  2. Add a Hidden field from the field types
  3. Configure the field key to match your attribution field names
  4. Add the corresponding CSS class for the attribution script to target

Elementor Forms

If you are using Elementor Pro's form widget:

  1. Edit your form widget
  2. Add new fields with Type set to "Hidden"
  3. Set the ID to match your attribution field names (e.g., sp_source)
  4. Leave the Default Value empty, the attribution script will populate it

Fluent Forms

Fluent Forms supports hidden fields through its Advanced Fields:

  1. Open the form in the Fluent Forms editor
  2. Add a Hidden Field from the Advanced Fields section
  3. Set the name attribute and CSS class to match your attribution field names

Installing the Attribution Script on WordPress

Once hidden fields are in place across your forms, you need the attribution script running on every page. There are several ways to add a script to WordPress:

Option 1: Theme Header (functions.php)

Add the script via your theme's functions.php file or a code snippets plugin. This ensures it loads on every page.

Option 2: Plugin

Use a script injection plugin like "Insert Headers and Footers" or "WPCode" to add the tracking script to your site header. This approach survives theme updates.

Option 3: Google Tag Manager

If you already use GTM, you can add the attribution script as a Custom HTML tag that fires on All Pages.

SourceStream provides a single script tag that works with all of these installation methods. Add it once, and it automatically detects and populates hidden fields in Contact Form 7, Gravity Forms, WPForms, Ninja Forms, Elementor Forms, Fluent Forms, and any other plugin that uses standard HTML form elements.

Verifying Your Setup

After installation, verify everything works:

  1. Visit your site with UTM parameters. Add ?utm_source=test&utm_medium=test&utm_campaign=test to any page URL.
  2. Navigate to a page with a form. Open your browser's developer tools (F12) and inspect the form. The hidden fields should be populated with the UTM values.
  3. Submit the form. Check the notification email (or CRM record) to confirm the attribution data was included.
  4. Test without UTMs. Visit from a Google search or social media link. The script should capture the referrer and organic source information.

What Data Gets Captured

A properly configured WordPress attribution setup captures the following for every lead:

  • Source: google, facebook, linkedin, newsletter, etc.
  • Medium: cpc, organic, social, email, referral
  • Campaign: the campaign name from UTM parameters
  • Channel: the broad channel category (Paid Search, Organic Search, Social, Email, etc.)
  • Landing Page: the first page the visitor saw on your site
  • Referrer: the full URL they came from
  • Click IDs: gclid (Google Ads), fbclid (Facebook), li_fat_id (LinkedIn), etc.

This data turns every WordPress form submission from a simple contact record into a fully attributed lead with a complete source story.

From Lead Source Data to Better Marketing

Once attribution data is flowing with every form submission, you can start answering the questions that matter:

  • Which marketing channels drive the most form submissions?
  • Which landing pages have the highest conversion rates?
  • Are paid ad leads better or worse than organic leads?
  • Which campaigns generate leads that actually become customers?

These insights directly inform your budget allocation, content strategy, and campaign optimization. No more guessing about which channels work. The data is right there in your form submissions and CRM records.

SourceStream was built specifically for this use case. It works with every major WordPress form plugin, captures comprehensive attribution data, and requires no ongoing maintenance. Set it up once and every WordPress lead comes with complete source tracking.

Start tracking your lead sources today

SourceStream captures every marketing touchpoint and flows attribution data directly into your forms and CRM. Set up in under 5 minutes.

Try SourceStream Free for 14 Days

No credit card required