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.

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") over the same window and compare totals. Where they diverge, trust Stripe 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

Put this playbook to work

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