Skip to content

How to pass UTM parameters from the form into the client’s CRM

Example product scene: a form lead sent by webhook, keeping its source and Lead ID for the outcome

UTM parameters only help once they reach the client’s CRM. A lead that arrives without its source can’t be credited to any campaign, and the campaign details usually get lost on the way to the form or between the form and the CRM. Each step below closes one of those gaps.

Where the source gets lost

  • The visitor opens another page before filling in the form, and the UTM values were only in the first page’s address.
  • The form has no fields for the values, so the submission carries the person but not the campaign.
  • The form tool or automation sends the lead to the CRM without mapping the extra fields.
  • The CRM writes its own default, such as “Website”, into the lead source field and overwrites what came in.

Step 1: Tag every ad link the same way

UTM parameters are labels added to the end of a link. Google Analytics documents nine of them in its URL builder guide and says to always set utm_source, utm_medium and utm_campaign; utm_term and utm_content separate keywords and ad variants, and Google also recommends utm_id. Agree on a naming pattern for each client, keep values lowercase, and use campaign names the client will recognize in the report.

Example tagged landing page link
https://example.com/roof-replacement?utm_source=google&utm_medium=cpc&utm_campaign=spring-roof&utm_content=ad-a

Google Ads can also add its own click identifier, gclid, through auto-tagging. Capture it beside the UTM values; it identifies the exact click if you later need to match a lead back to Google Ads.

Step 2: Keep the values while the visitor browses

Read the values on the first page and store them in the browser, so a form two pages later can still use them. Decide which visit wins when someone arrives twice: keeping the first values gives first-touch credit, replacing them gives last-touch credit. Our article on first-touch and last-touch attribution helps you choose.

Session storage lasts until the tab is closed. A first-party cookie lasts longer but may need consent where privacy law requires it, so check the client’s cookie banner settings before adding one.

Step 3: Copy the values into hidden form fields

Add one hidden field per value, named exactly like the parameter. The script below keeps the first values seen in the tab and fills any matching hidden field on the page. Run it after the form has loaded, and test it on the client’s site before relying on it. Forms embedded from another domain in an iframe can’t be reached by the page’s script and need the form tool’s own hidden-field setting.

Keep UTM values and fill hidden fields
// Keep the first UTM values seen in this tab, then copy them into matching hidden fields.
const KEYS = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'utm_id', 'gclid'];
const params = new URLSearchParams(window.location.search);
for (const key of KEYS) {
  const value = params.get(key);
  if (value && !sessionStorage.getItem(key)) sessionStorage.setItem(key, value);
}
for (const key of KEYS) {
  const value = sessionStorage.getItem(key);
  if (!value) continue;
  document.querySelectorAll(`input[type="hidden"][name="${key}"]`).forEach(field => { field.value = value; });
}

Step 4: Map each field into the CRM

Create a text field in the CRM for each value and map the form’s hidden fields to them. Text fields accept any campaign name, while a fixed drop-down list can reject or rewrite values it doesn’t recognize.

Example mapping from hidden fields to CRM fields
Hidden fieldCRM fieldExample value
utm_sourceOriginal sourcegoogle
utm_mediumOriginal mediumcpc
utm_campaignOriginal campaignspring-roof
utm_contentAd or variantad-a
gclidGoogle click IDAdded by auto-tagging

Protect the original values. If the CRM or a later automation can update these fields, the next website visit can replace the campaign that actually produced the lead.

Step 5: Send a tagged test lead and check the record

  1. Open the landing page through a tagged link in a private window.
  2. Click through to a second page, then submit the form with a name you will recognize.
  3. In the browser’s network panel, confirm the submission carried the UTM fields.
  4. Open the new CRM record and check that each field holds the value from the link.
  5. Delete or mark the test record so it never reaches a client report.

Calls, chats and offline leads need their own path

Hidden fields only help when someone fills in a form. A caller from the same ad leaves no UTM values behind unless a tracking number identifies the campaign. Chats, walk-ins and referrals need a source chosen at the moment the lead is entered. Whatever the path, record the source once, when the lead is created.

Where Attrival fits in this chain

Attrival starts when the lead arrives: the webhook or form connection passes the source and campaign, and Attrival keeps them as the lead’s original attribution. When the job changes in the client’s CRM, the outcome comes back to the same lead, found by its Lead ID or the customer’s email, phone or name, and so to the same campaign. A missing value stays unknown instead of being guessed.

The lead-to-outcome setup guide shows how to check that chain with one test lead, and campaign attribution shows what the report does with the source once it arrives.

Read next on lead sources.

Keep the campaign on every lead you deliver.