Skip to main content
Terminus
Contents
Going DeeperChapter 10 · ~7 min read

Integration and Automation

CRM integration, lead capture, APIs, and ETL pipelines.

On this page

A salesperson opens a new lead record and sees: ‘Source: linkedin, Medium: paid_social, Campaign: q1_awareness.’ Without asking marketing a single question, they know exactly how this prospect found them, and what message resonated.

That’s the payoff of connecting UTM data to your CRM.

UTM data earns its full value once it leaves web analytics and flows into the CRM, the marketing automation platform, and the data warehouse. Three skills carry it there, and this page teaches all three: capturing UTM parameters at the point of conversion, passing them into your sales systems, and automating the workflows that keep the whole pipeline running.

Capturing UTMs in Lead Forms

When a user arrives via a UTM-tagged URL and fills out a form, capture those parameters alongside the submission. The technical process:

  1. UTM Parameter Persistence: When a user lands on a page, JavaScript reads the UTM parameters from the URL query string. Since users may navigate to other pages before converting, store these values to persist throughout their session:

    • Session cookies: Expire when the browser session ends.
    • Persistent cookies: Longer expiration, useful for first-touch attribution across multiple sessions.
    • Browser storage: Session Storage or Local Storage APIs.

    The choice depends on your attribution window. Capture both first-touch and last-touch UTM values; they provide different attribution perspectives.

    First-Touch vs. Last-Touch UTM Capture
    ═══════════════════════════════════════
    
    Session 1 (Week 1)           Session 2 (Week 2)         Session 3 (Week 3)
    google / cpc /               linkedin / paid_social /    newsletter / email /
    spring_sale                  spring_sale                 spring_sale
         │                            │                           │
         │                            │                           ▼
         │                            │                      ┌──────────┐
         │                            │                      │ CONVERTS │
         │                            │                      │ (form    │
         │                            │                      │  fill)   │
         │                            │                      └──────────┘
         │                            │                           │
         ▼                            │                           ▼
    First-Touch UTMs              (not captured                Last-Touch UTMs
    stored on lead:               unless you build             stored on lead:
    source = google               multi-touch tracking)        source = newsletter
    medium = cpc                                               medium = email
    campaign = spring_sale                                     campaign = spring_sale
    
    First-touch answers: "What brought them in?"
    Last-touch answers:  "What triggered the conversion?"
    You need both for a complete picture.
  2. Populating Hidden Form Fields: Include hidden input fields for each UTM parameter in your lead forms (e.g., <input type="hidden" name="utm_source">).

  3. Data Transfer on Submission: JavaScript retrieves the stored UTM values and populates the hidden fields before form submission. The UTM data is sent to the server alongside the visible form data (name, email, etc.).

Some CRM platforms (e.g., HubSpot) automatically capture UTM parameters when their tracking code and forms are used. Explicit hidden fields give you more control and work with any form.

TRY IT · Follow the lead into the CRM

Step 1: The ad is clicked

Terminus · Sponsored

Stop cleaning UTM data. Start trusting it.

Destination: yoursite.com/demo?utm_source=linkedin&utm_medium=paid_social&utm_campaign=q3-enterprise-demo

Step 2: The landing page loads

Two things happen: GA4 records the session with source / medium / campaign, and a capture script stashes the three UTM values in a first-party cookie. They must survive while the visitor browses other pages.

Step 3: The form is submitted (20 minutes later, different page)

Name
Jordan Lee
Work email
jordan@acme.com
utm_source (hidden)
linkedin ← read from the cookie
utm_medium (hidden)
paid_social
utm_campaign (hidden)
q3-enterprise-demo

Step 4: The CRM lead record

Lead
Jordan Lee · Acme Corp
Original source
linkedin
Original medium
paid_social
Original campaign
q3-enterprise-demo

When this deal closes for $48k, marketing can prove the LinkedIn campaign drove it, because three little parameters survived the whole journey.

That trace is Stride’s spring sale in miniature. A customer clicks the Facebook ad for spring_sale-runners-2025_03, browses, and leaves; two weeks later she clicks a link in the weekly newsletter and fills out the “Get 10% Off” form. Here’s what flows into Stride’s HubSpot:

CRM FieldFirst-Touch ValueLast-Touch Value
UTM Sourcefacebooknewsletter
UTM Mediumpaid_socialemail
UTM Campaignspring_sale-runners-2025_03spring_sale-runners-2025_03
UTM Contentvideo-testimonial-runner-15seccta-shop-now

The sales team sees both touches on the contact record: first-touch says Facebook brought her in, last-touch says the newsletter triggered the conversion, and the identical campaign value confirms it’s the same initiative across channels.

It’s also how Dana answers the CEO at quarter’s end. She queries HubSpot for all contacts where utm_campaign = spring_sale-runners-2025_03, groups by first-touch source, and reports with real data: the spring sale generated 312 leads. Facebook drove 41% of first touches, email drove 28%, Google Ads drove 22%, and the retail QR codes drove 9%. The QR codes had the highest conversion rate at 12%, so the in-store displays are worth the printing cost. That answer was impossible eight weeks ago, and the only thing that changed is consistent UTM values flowing from governed links through hidden form fields into the CRM.

Beyond Two Touches: Multi-Touch Tracking

First-touch and last-touch capture gives you the bookends of the journey. But for multi-touch attribution models (linear, time-decay, position-based; see Chapter 9), you need the middle touches too.

The technical challenge: each session may carry different UTM values, and you need to store all of them, not just overwrite with the latest.

Implementation approaches:

  • Cookie/localStorage array: Instead of storing a single set of UTM values, maintain a JSON array of all touchpoints with timestamps. Append each new visit’s UTMs rather than overwriting. This gives you a client-side record of every tagged interaction.
  • Server-side event log: Send each UTM-tagged visit as a separate event to your backend or data warehouse. Join by user ID or anonymous ID later. This approach survives cookie clearing and cross-device journeys.
  • Marketing automation platforms: Tools like HubSpot and Marketo maintain interaction timelines that capture each touchpoint automatically when their tracking is properly configured. If you already use one, check whether it handles multi-touch natively before building a custom solution.

The key architectural decision: decide early whether you’ll track touchpoints client-side (simpler, but limited by cookie/storage constraints and device boundaries) or server-side (more robust, but requires engineering investment). Retrofitting is painful. This is easier to get right at the start.

Passing UTM Data to CRMs

Enrich CRM lead and contact records with UTM data to bridge marketing activities and sales outcomes.

Field mapping: Create custom CRM fields for each UTM parameter (UTM Source, UTM Medium, UTM Campaign, etc.). Map form submission data to these fields via your backend or integration layer.

HubSpot: Automatically captures UTM parameters when its tracking code and forms are used. Stores interaction history across touchpoints. Custom properties can explicitly store specific UTM values.

Salesforce:

  1. Create custom fields on the Lead object for UTM parameters.
  2. Map these values to Contact and/or Opportunity fields upon lead conversion.
  3. For Campaign Influence reporting, create custom fields on Campaign Member and use automation (Flow or Apex triggers) to associate leads with the corresponding Salesforce Campaign based on UTM values.

What the integration buys you:

  • Enriched lead profiles: Sales teams get immediate context on how a lead was acquired.
  • Lead quality analysis: Marketing can analyze lead quality (lead-to-opportunity conversion rates, deal size) by UTM source, medium, and campaign.
  • Closed-loop reporting: Linking marketing touchpoints (via UTMs) to sales outcomes (revenue) is what makes true ROI calculation possible.
  • Sales and marketing alignment: Shared data fosters collaboration between teams.

CRM integration creates a traceable lineage from ad click to closed deal, so reports like “Revenue by UTM Campaign” and “Lead-to-Opportunity Conversion Rate by UTM Source” become routine queries instead of special projects.

Mobile App Deep Linking

When campaigns drive users to a mobile app instead of a website, attribution runs through a mobile measurement partner (MMP) like Branch, AppsFlyer, or Adjust, and each has its own dialect for campaign parameters. Branch attributes from its own analytics tags; its documented UTM mapping runs outbound only, translating those tags into UTMs on web redirects, not reading yours in. AppsFlyer reads UTMs only as a fallback when its own parameters are absent. Adjust doesn’t read UTMs at all; it expects its own campaign, adgroup, and creative parameters. Whichever you run, the install or in-app event gets attributed to the campaign values carried on the click URL, so your taxonomy still supplies those values; they just need translating into each MMP’s parameter names.

The governance principles are identical: consistent naming, controlled vocabularies, and approved values matter just as much. Arguably more, since app attribution is harder to debug than web: if a misspelled campaign value lands in your MMP, you won’t catch it by inspecting a page URL in a browser.

If your campaigns can land on either web or app, share one set of UTM conventions across both destinations. Different naming in web vs. app tracking recreates the exact fragmentation problem the rest of this guide solves. A single taxonomy governs all touchpoints, regardless of where the user ends up.

This is a brief acknowledgment, not a deep dive. Defer to your MMP’s documentation for implementation specifics around deep link configuration, deferred deep linking, and platform-specific attribution windows.

Marketing Automation Platforms

Marketing automation platforms (HubSpot, Marketo, Pardot, ActiveCampaign) sit between your website and your CRM, and they handle UTM data in different ways.

  • HubSpot: Automatically captures UTM parameters when its tracking code is installed. Stores original source, latest source, and interaction history on contact records. Custom properties can capture specific UTM dimensions beyond the defaults.
  • Marketo: Munchkin logs each visit, query string included, to the person’s activity history, but it never writes UTM values to a field on its own. Use hidden fields on Marketo forms, populated from URL parameters or a first-touch cookie, for reliable capture, and map those fields explicitly to pass values to Salesforce lead/contact records.
  • Pardot (Marketing Cloud Account Engagement): Captures UTMs into dedicated Google Analytics prospect fields via its Google Analytics connector, and only on a prospect’s very first tracked touch; a visitor who already carries a tracking cookie never gets the values. Past first touch, hidden fields and form handlers are the reliable path. None of it happens without enabling the connector first.
  • ActiveCampaign: Parses UTM parameters through its site tracking script and records each tagged visit as an attribution touchpoint on the contact record. Getting the values into contact fields you can segment on takes extra setup.

The common pitfall across all four: each has its own default behavior for handling UTM data, and none of them enforce your taxonomy. You still need governed link creation upstream. The automation platform captures whatever values arrive in the URL, clean or messy. Garbage in, garbage out applies here just as much as it does in raw analytics.

APIs for UTM Generation and Validation

At scale, manual UTM management becomes a bottleneck. APIs give you programmatic control.

  • UTM generation: Platforms like Terminus and CampaignTrackly offer APIs to programmatically create, update, and manage tagged links: bulk creation (thousands of links), auto-tagging from CMS/PIM systems, and custom internal tools.
  • UTM validation: Integrate API calls into campaign workflows to check that UTM values match approved taxonomies before deployment. This prevents errors at the source.
  • Data extraction: Analytics platforms (GA4 API, Adobe API), ad platforms (Google Ads, Facebook Ads), and CRMs (HubSpot, Salesforce) provide APIs to extract UTM-tagged performance data for custom dashboards, data warehouses, and BI tools.

ETL: Connecting to Data Warehouses

For cross-functional analysis, UTM-enriched data from analytics, CRMs, and ad platforms flows into a central data warehouse via ETL (Extract, Transform, Load) pipelines.

  • Extract: Pull raw data from source APIs: web analytics (UTM dimensions), CRM (leads, sales outcomes), ad platforms (spend, clicks).
  • Transform: Clean and reshape for analysis:
    • Parse structured campaign values or CIDs into constituent parts
    • Standardize inconsistent source names and handle missing values
    • Join datasets using common keys (utm_campaign, utm_id, user ID)
    • Apply business rules (custom channel groupings, derived metrics)
  • Load: Insert transformed data into the warehouse (Snowflake, BigQuery, Redshift) for querying by BI tools and data science platforms.

ETL best practices: Plan objectives before building; validate data quality at every step; use incremental loading for performance; build modular, scalable pipelines; maintain comprehensive logging. For data engineers and analytics engineers who want the implementation details (schema design, dbt models, SQL parsing patterns, and taxonomy version handling), see For Data Teams.

Example End-to-End Workflow

  1. Campaign planning: A new campaign is planned in your project management tool. Taxonomy dimensions (audience, objective, channels) are defined.
  2. UTM link generation: All destination URLs are tagged using a governed UTM builder (like Terminus), with unique campaign IDs generated. This may be triggered via API from the planning tool.
  3. Link deployment: Tagged URLs are embedded into emails (via ESP), used as ad destination URLs, shortened for social posts, and placed in blog CTAs.
  4. Data capture: Analytics platforms capture UTM parameters with session data. If the user converts, UTM values (first-touch and last-touch) flow to the CRM via hidden form fields.
  5. Data aggregation: Via APIs and ETL, data from analytics, CRM, ad platforms, and the UTM management platform is extracted, transformed, and loaded into a data warehouse.
  6. Analysis: BI tools query the warehouse for full-funnel performance, cross-channel attribution, and marketing ROI dashboards.

APIs and ETL mark the transition from basic campaign reporting to integrated business intelligence, where UTM data informs not just marketing but sales strategy, budget allocation, and executive decision-making.

This is where attribution (Chapter 9) and integration close the loop: clean UTM data flows into your CRM and warehouse, attribution models allocate credit across touchpoints, and the resulting insights inform budget decisions with real revenue data behind them.


Key Points

  • Capture first-touch and last-touch UTM values in lead forms; they answer different attribution questions
  • For multi-touch attribution, decide early between client-side and server-side touchpoint tracking; retrofitting is painful
  • CRM integration (HubSpot, Salesforce) is the link between marketing spend and actual revenue
  • Marketing automation platforms capture UTM data, some automatically and some only with setup, and none enforce your taxonomy; governance still happens upstream
  • If campaigns can land on web or app, one UTM taxonomy covers both destinations
  • APIs give you programmatic UTM generation, validation, and data extraction at scale
  • ETL pipelines bring UTM-enriched data into data warehouses for cross-functional analysis

Action Item: Check whether your lead forms capture UTM parameters today. If they don’t, add hidden fields for utm_source, utm_medium, and utm_campaign. One small change, and closed-loop reporting between marketing and sales becomes possible.

Next upChapter 11: UTM Tracking in Google Analytics 4