How to capture Google Analytics data in Netlify Forms
Google Analytics tells you which channels bring visitors to your site, but a session report will not tell you the name of the person who filled in your contact form or which campaign produced that lead. This guide closes that gap: you add hidden fields to your Netlify form, a small script writes channel and landing-page values into them at submit time, and Netlify stores those values next to the visitor's name, email and phone number. From there you can read the source beside each lead in the Netlify dashboard, include it in notification emails, or forward it to a CRM or spreadsheet for reporting.
Why session analytics stops short of lead attribution
A traffic report answers a different question from the one most sales teams ask. It can tell you the volume of visits that arrived through paid search, paid social or organic search, and which pages those visits touched. It cannot, by itself, name the person who submitted your form or tie that person back to the campaign that brought them in. Attribution closes that loop by carrying the source alongside the submission, so a report can count leads and customers per channel instead of sessions per channel. The practical payoff: you learn not just that a channel attracts visitors, but whether it produces pipeline.
What the script does, in plain terms
A small snippet of code is placed on the site. On each visit it works out where the visitor came from and sorts the visit into a channel such as Paid Search, Paid Social or Organic Search — the same style of grouping you see in analytics tools. When that visitor reaches a lead capture form, the script writes the source values into hidden fields. On submit, Netlify records those values along with whatever the visitor typed. Nothing about the form looks different to the visitor, because hidden fields are present in the markup but not displayed.
Step 1 — Add the six hidden fields
Create these hidden fields on every form whose submissions you want attributed. The names matter, because the script looks for them:
- Channel
- Channel Drilldown 1
- Channel Drilldown 2
- Channel Drilldown 3
- Landing Page
- Landing Page Group
Add them to each form individually; a form without them will still submit, but it will carry no source data. Detailed field-adding instructions are linked in the resources at the end of this page.
Step 2 — Let the script populate the fields
You do not type values into these fields. When a visitor completes a form, the script fills them based on how that visitor arrived. A worked example makes the pattern clear. Imagine an e-commerce platform running Google Ads: a visitor clicks an ad, lands on a tools page and submits a form. The fields would then read Channel = Paid Search, Channel Drilldown 1 = Google, Channel Drilldown 2 = the campaign name, and Channel Drilldown 3 = the platform name. The landing page field would hold the first page they saw, such as a /tools/ecommerce URL, and the landing page group would hold the section, such as /tools.
Step 3 — Netlify Forms stores the values with the submission
On submit, Netlify captures the hidden field values together with the details the lead entered — name, email, phone number and anything else on the form. The two sets of data arrive as one submission record, which is what makes per-lead reporting possible later.
Step 4 — Put the captured data to work
With source data attached to each submission you have four practical destinations:
- Read the source for an individual lead in the Netlify dashboard.
- Add the source fields to the new-lead notification email so sales sees origin immediately.
- Forward submissions to a CRM such as Salesforce, HubSpot or Pipedrive.
- Export to a spreadsheet and build channel or campaign reports.
Pick based on who acts on the data. A small team may only need the notification email; a team with a CRM will want the fields mapped there so reporting lives beside opportunity and customer records.
What actually gets captured
Two families of information come through. The first is the channel, which describes the route the lead took — organic search, paid search, paid social, referral and others. For some channels the drilldown fields add campaign, ad group, keyword and similar detail. The second is landing page context: the first page the visitor viewed and the group that page belongs to. Together they answer both "which channel?" and "which content?" for every lead.
A field map and a pre-launch check
Use this map when wiring the fields into Netlify, your CRM or a spreadsheet:
- Channel — the grouped source type; the field to group reports by first.
- Channel Drilldown 1 — the next level down, typically the platform or network.
- Channel Drilldown 2 — campaign-level detail where available.
- Channel Drilldown 3 — the finest level, such as keyword or ad group.
- Landing Page — the first page the visitor saw.
- Landing Page Group — the section that page belongs to.
Before launch, check four things: every target form has all six fields; the field names match exactly; a test submission shows values in the Netlify dashboard; and any CRM or spreadsheet mapping uses the same names. If a submission arrives with the lead's details but empty source fields, the usual cause is a missing or misnamed hidden field rather than a broken form. If the fields exist but stay empty across all submissions, check that the script is present on the pages where forms appear.
Three reports worth building
Start with a count of leads per channel. This is the widest lens: it shows which routes fill your pipeline, and it is the first place to look when spend and results seem out of step. Suppose most leads trace back to organic search while the largest share of budget goes to paid search — that gap is a signal to revisit the split rather than keep funding on autopilot. Next, narrow to individual Google Ads campaigns and compare how many genuine sales opportunities each one opens. Campaigns that consistently convert can absorb more budget; those that only generate clicks can be paused. Finally, if you advertise through Facebook, your placements may span the networks it owns — Facebook, Instagram, Messenger and WhatsApp. A customers-by-network report shows which of those placements actually yields paying customers, so budget follows the network that delivers, not just the one with the most impressions.
Getting started
Setup is a short job: add the fields, place the script, submit a test form and confirm the values appear. Trial length, plan pricing, any free-tier allowance and the expected setup time are commercial terms the site owner confirms before publishing; see the owner input notes accompanying this page.
| Hidden field | What it holds | Example value |
|---|---|---|
| Channel | Grouped source type | Paid Search |
| Channel Drilldown 1 | Platform or network level | |
| Channel Drilldown 2 | Campaign level | Ecommerce Campaign |
| Channel Drilldown 3 | Finest level, e.g. keyword or ad group | Shopify |
| Landing Page | First page the visitor viewed | www.shopify.com/tools/ecommerce |
| Landing Page Group | Section that page belongs to | /tools |
Example values illustrate how the fields can be populated for a paid search visit; actual values depend on how the visitor arrived.
Frequently asked questions
Do hidden fields change what visitors see on the form?
No. Hidden fields exist in the form but are not displayed, which is why a script can write into them without the visitor noticing.
Where can the captured source data be viewed?
In the Netlify dashboard against each submission, in new-lead notification emails if you add the fields there, and in a CRM or spreadsheet once submissions are forwarded.
What is the difference between Channel and the drilldown fields?
Channel is the broad grouping, such as Paid Search or Organic Search. The drilldowns add progressively finer detail — platform, campaign, then keyword or ad group where available.
Why would a submission arrive without any source data?
Most often a hidden field is missing from that particular form or its name does not match what the script expects. Confirm all six fields exist on the form and that the script loads on the page.