Skip to content

How to capture Facebook Ads data in WordPress forms

If you run Facebook Ads and collect leads through a WordPress form, the form usually tells you a name and an email but nothing about the ad that produced the click. This guide shows a repeatable way to attach campaign, ad set, ad and landing-page details to every submission so you can compare campaigns on leads rather than clicks alone.

What you are trying to capture

The goal is simple: when a visitor arrives from a Facebook ad and later submits a form, the submission should carry the ad's identity. That means the campaign name, the ad set, the specific ad, the channel (Paid Social) and the landing page they first saw. Once those values travel with the lead, you can answer questions like 'which campaign produced the most leads last month?' without guessing from click totals.

The mechanism has two parts. First, the ad's destination URL carries UTM parameters that describe the campaign. Second, a small script on your site reads those parameters, remembers them in the visitor's browser, and writes them into hidden fields on your form at submission time. Your form builder then stores them alongside the visible answers.

Step 1: Tag your Facebook Ads with UTM parameters

A UTM parameter is a labelled key-value pair tacked onto the end of a destination link. The page itself renders the same; what changes is the record of how the click was labelled. For Facebook Ads, a consistent pattern keeps reporting clean:

  • utm_medium = paid social
  • utm_source = facebook
  • utm_campaign = the campaign name
  • utm_term = the ad set name
  • utm_content = the specific ad

A sample destination might look like this: https://roipaths.com/integrations/wordpress?utm_medium=paidsocial&utm_source=facebook&utm_campaign=brand-campaign. The exact values are yours to choose, but keeping the medium and source stable across every ad is what makes later grouping reliable. Free campaign URL builders exist if you prefer a form to assemble the string.

One practical tip: decide your naming convention before you launch the first ad. Renaming a campaign later does not rewrite the UTMs already stored on past leads, so a consistent scheme from day one saves cleanup.

Step 2: Add the attribution script to your WordPress site

A small attribution snippet is placed on the site. On each visit it inspects how the person arrived and classifies them into a channel such as Paid Social, Paid Search, Organic Search or Organic Social — the same broad categories you see in web analytics tools. When the visitor submits a form, the script writes the derived values into hidden fields that your form builder captures. The snippet is a generic tracking script, so the same mechanism works whether you use a dedicated attribution product or a custom implementation you maintain yourself; what matters is that it reads the UTM parameters and populates the hidden fields before submission is processed. If you build your own, keep the field names and the channel mapping documented so the form builder and the script stay in sync. If you use a hosted tool, follow its installation guide for WordPress, which usually means adding a script tag to the site header or a plugin-managed snippet area. The important check is that the snippet loads on every page where a form appears, not only the home page. A quick way to confirm this is to open a few different pages with forms, view the page source or the browser's network panel, and check that the script is present on each one.

Step 3: Add hidden fields to your forms

Your form needs a place to receive the data. Add these hidden fields to each form you want to track:

  • Channel
  • Channel Drilldown 1
  • Channel Drilldown 2
  • Channel Drilldown 3
  • Landing Page
  • Landing Page Group

Most WordPress form tools — Gravity Forms, Contact Form 7 and WPForms among them — let you add hidden fields without code. The field names must match what the script expects; a typo in a field label is one of the most common reasons data arrives blank.

A useful way to think about the three drilldowns: for a Facebook click, Drilldown 1 typically holds the source or campaign level, Drilldown 2 the ad set, and Drilldown 3 the specific ad. The exact assignment depends on how the script maps your UTMs, so confirm the mapping once with a test submission rather than assuming.

Step 4: Confirm the data is captured on submission

With the snippet and the hidden fields in place, the script begins recording where visitors come from. A visitor who clicks a Facebook ad has the UTM values stored in a cookie in their browser. If they leave and return days later, the stored values are still available. When they finally submit a form — a contact form, a quote request, a demo booking — the script writes the Facebook-derived values into the hidden fields, and the form builder saves them with the lead's name and email.

To verify, submit a test form after clicking a tagged link. Check the stored entry in your form builder: the Channel field should read Paid Social and the drilldown fields should reflect your campaign, ad set and ad. If the fields are empty, the snippet or the field names are the first things to check.

Where the captured data can go

Once each lead carries its source, you have three common destinations:

  • A CRM such as Salesforce, HubSpot or Pipedrive. Reports there can show leads by campaign, how many became customers, and revenue generated.
  • A spreadsheet. Export leads as CSV from the form builder, or push them to a Google Sheet with an automation tool, then build charts or connect a BI tool such as Google Data Studio or Microsoft Power BI.
  • Your inbox. Append the attribution values to the new-lead notification email so you can see the source while replying.

Each destination answers a different question. The CRM is best for revenue and customer conversion; the spreadsheet is best for quick exploratory charts; the email is best for day-to-day context when you respond to a lead personally.

Why the script approach beats relying on the ad platform alone

Ad platforms report clicks and impressions, but they cannot see what happens inside your form or CRM. A script that writes source data into the form closes that gap in three ways.

Coverage: the same classification runs on every arrival, so a lead from Paid Search, Organic Search or Organic Social is labelled as readily as one from Facebook. That gives you a like-for-like comparison across channels instead of a Facebook-only view.

Memory: because the values sit in a browser cookie, a visitor who clicks an ad on Monday and submits a form on Thursday still carries Monday's source into the submission.

Tolerance for messy tags: teams rarely spell utm_source the same way twice — facebook in one campaign, facebook.com in another. The script normalises those variants so both land in Paid Social, which keeps channel totals from splitting apart.

Landing page data adds a second dimension

Alongside the ad details, the script records the landing page URL and a landing page group. The group is the section of the site — for example, /blog — while the URL identifies the individual page. That lets you report on leads generated by a whole content section and then drill into a single article. For Facebook campaigns that send traffic to blog posts or landing pages, this is often as informative as the campaign name itself.

Three reports worth building first

Once the data is flowing into a CRM or spreadsheet, start with three views.

  1. Leads by channel. A monthly count of leads per channel (Paid Social, Paid Search, Organic Search and so on) gives a high-level picture of what is driving leads and where to invest.
  2. Leads by network. If you advertise across Facebook, Instagram, Messenger or WhatsApp, grouping by ad network shows which app produces the most leads at the lowest cost.
  3. Leads by campaign. A per-campaign lead count separates campaigns that generate actual form submissions from those that generate clicks but no conversions.

These are starting points, not a fixed dashboard. Add revenue or customer-conversion columns once your CRM data is reliable enough to support them.

Pre-launch checklist

Before you rely on the numbers, run through this list. Treat each item as a question you answer with evidence from a test submission rather than an assumption about how the setup behaves. Every Facebook ad destination URL should carry the agreed UTM parameters, and you can confirm this by opening the ad's link in a browser and checking the query string. The attribution snippet should load on every page that contains a form, which you can verify by inspecting a few representative pages. Each form should have all six hidden fields, spelled exactly as the script expects, because a mismatched label is a common cause of blank data. A test submission from a tagged link should show Paid Social in the Channel field and the expected campaign, ad set and ad in the drilldowns. The form builder's notification email or CRM integration should include the hidden field values, so check one real or test notification end to end. A returning-visitor test should confirm the source is still recorded after a delay, which tells you the cookie-based memory is working as intended. If a test submission shows blank fields, the cause is usually a missing snippet or a mismatched field name. If the fields are populated but the channel is wrong, the UTM values themselves are the likely culprit. Setup effort and cost terms are not stated here; confirm the current trial length, pricing and setup time directly with the tool provider before you commit, and record those terms in your own project notes.

Frequently asked questions

Do I need a CRM to use this?

No. The captured values live in your form builder's entries, so you can export them as CSV or push them to a spreadsheet. A CRM adds revenue and customer-conversion reporting, but it is not required to see which campaign produced a lead.

What happens if a visitor clicks a Facebook ad, leaves, and returns later?

The UTM values are stored in a cookie in the visitor's browser, so they remain available when the person returns and submits a form days later. The submission still records the original Facebook source.

Will inconsistent UTM values break the channel reporting?

The script is designed to handle common inconsistencies, such as utm_source=facebook in one campaign and utm_source=facebook.com in another. Both are assigned to the Paid Social channel, so the channel totals stay accurate even when the source string varies.

Which WordPress form builders support hidden fields?

Most do, including Gravity Forms, Contact Form 7 and WPForms. The requirement is that the builder lets you add hidden fields and that the field names match what the attribution script writes into.

What is the difference between Channel and Channel Drilldown?

Channel is the broad category — for example, Paid Social. The three drilldown fields hold progressively finer detail, typically the campaign, ad set and specific ad for a Facebook click. The exact mapping depends on how your UTMs are structured, so confirm it with a test submission.