Marketing

Lead source to revenue attribution

Measure marketing ROI by source: trace channels and campaigns through to closed revenue by joining CRM deals with payment records, so revenue per lead and return on spend are known instead of stopping at lead counts.

  • +1
    Which lead sources close the most deals?
  • +1
    What's our revenue per lead by channel?
  • +1
    Do CRM closed-won numbers match what got paid?

The playbook

Most channel reports stop at leads. The channel producing the most leads is frequently not the one producing the most revenue, and that gap is the entire point of this analysis.

Steps

  1. Understand the CRM shape before querying it. Call hubspot.list_properties for contacts and deals to find the actual source field — it may be hs_analytics_source, a custom property, or something team-specific. Call hubspot.list_pipelines for deals to learn which stage IDs mean "closed won". Do not hardcode either; they differ per account.

  2. Pull deals with their source and value. hubspot.search_deals with filterGroups scoping to the period, requesting properties including deal name, amount, close date, stage, and the source property you identified. Page through with after until complete — a partial pull silently biases every number downstream.

  3. Pull the contacts behind those deals via hubspot.search_contacts when you need the original acquisition source rather than the deal-level one. The deal source is often inherited or overwritten; the contact's first-touch source is usually closer to the truth.

  4. Reconcile against actual payments. CRM "closed won" is a human-entered state; money received is not. Use stripe.list_charges or stripe.list_invoices (with status: "paid"), or dodo_payments.list_payments with status: "succeeded", over the same window and compare totals. Where they diverge, trust the payment provider for revenue and report the discrepancy — it's usually a finding in its own right.

  5. Add top-of-funnel volume for context. google_analytics.run_report with dimensions: ["sessionSourceMedium"] and metrics: ["sessions", "conversions"] shows how much traffic each channel needed to produce those deals.

  6. Report. One row per source: sessions, leads, deals created, deals won, revenue, and revenue per lead. Sort by revenue. Then explicitly contrast the lead-volume ranking against the revenue ranking — where they disagree is the recommendation.

Gotchas

  • Attribution windows. A deal closing this month may come from a lead generated months ago. Attributing by close date credits whatever channel was running then. Prefer joining on the contact's original source and note the lag.
  • HubSpot source values are messy. Free-text and legacy values proliferate. Normalize case and obvious duplicates before grouping, and say what you merged.
  • Stripe amounts are in the smallest currency unit (cents). Divide by 100 before reporting, and don't sum across currencies without converting — if multiple currencies appear, report them separately.
  • Deleted or test deals frequently sit in CRM data. Sanity-check the total against a known figure before presenting it.
  • Small numbers aren't signal. A channel with 3 deals and one large contract will top a revenue-per-lead table. Report deal counts alongside so the reader can see the sample size.

Sequel CLI

Install Sequel skills into your agent

One command connects your agent to Sequel and installs the Sequel skill, so it knows this playbook exists and reads it when a question matches. The CLI signs you in, provisions a scoped API key and writes the config for you.

Already have an MCP client?

https://api.sequel.sh/mcp

Point it at this URL and sign in when prompted, or send an API key from Settings as a Bearer token. Skills come with it; nothing else to install. Manual setup per client

  1. 1

    Install the Sequel CLI

    One line installs the latest CLI with whatever package manager you have.

    curl -fsSL https://sequel.sh/install | sh
  2. 2

    Sign in

    Authenticate in your browser and pick an organization.

    sequel login
  3. 3

    Install into your agent

    Writes the MCP config and installs the Sequel skill file for agents that support skills. Pick an agent from the list, or target one directly by its slug.

    sequel install
    • Claude Code
      sequel install claude-code
    • Claude
      sequel install claude
    • Cursor
      sequel install cursor
    • VS Code
      sequel install vscode
    • Windsurf
      sequel install windsurf
    • Zed
      sequel install zed
    • Codex
      sequel install codex
    • OpenClaw
      sequel install openclaw
    • Hermes
      sequel install hermes

FAQ

Frequently asked questions

What is lead source to revenue attribution?
Tracing which marketing source first acquired a lead all the way through to closed revenue in your CRM. It answers which channels generate leads that actually become customers, not just leads. A channel that produces many leads but zero closed deals is a volume metric that looks good but costs money.
What is the difference between first-touch and last-touch attribution?
First-touch credits the first interaction that brought the lead to your site. Last-touch credits the final interaction before conversion. Neither is complete. HubSpot defaults to first-touch from its own tracking cookie. GA4 defaults to last non-direct click. Report both and say which you used.
How do I connect HubSpot leads to marketing channels?
HubSpot stores the original traffic source on each contact as hs_analytics_source and the first landing page as hs_analytics_first_url. Search contacts filtered by source and group by first URL path. Join to Search Console or GA4 channel data on the path to build the lead source picture.
Why are some HubSpot leads showing as offline or unknown source?
Leads from cold email outreach, conference list uploads, or any source without the HubSpot tracking pixel will show as unknown. This is normal for outbound-heavy businesses. Report known-source leads as a share of total leads so the reader understands the coverage.
Can an AI agent run lead source to revenue attribution?
Yes. With HubSpot, Search Console, and GA4 connected, the agent joins lead source data with closed deals and returns revenue and pipeline by source with trend data. Sequel provides all three connections over MCP and the lead-source-to-revenue-attribution playbook.

Put this playbook to work

Connect a source, ask the question, and the agent follows these steps. Free to start.