Short answer

Export your deals with the first-touch utm_medium stored on each one, map every medium to a channel (inbound, paid, outbound) with a CASE expression, then group by channel. One query gives you deal count, pipeline, won revenue, win rate and each channel's share of pipeline.

Narrative Brand Labs, a fractional go-to-market and RevOps consultancy for mid-market B2B companies, uses this kind of report to answer a simple budget question: which channel is actually producing pipeline?

What you need first

This only works if each deal carries the source of the visit that created the lead. In an earlier post I showed how to capture UTM parameters in hidden form fields so the CRM stores first_utm_source and first_utm_medium on every contact. Copy those fields to the deal, then export deals to CSV.

Example deals.csv:

deal_id,amount,stage,created_date,first_utm_source,first_utm_medium 101,48000,Closed Won,2026-09-02,google,organic 102,120000,Proposal,2026-09-15,(direct),(none) 103,36000,Closed Lost,2026-10-01,linkedin,outbound 104,95000,Negotiation,2026-10-09,bing,cpc 105,60000,Closed Won,2026-10-20,newsletter,email 

The query (DuckDB)

DuckDB can read the CSV directly, so there is nothing to import.

WITH deals AS ( SELECT *, CASE WHEN lower(first_utm_medium) IN ('organic', 'referral', '(none)') THEN 'Inbound' WHEN lower(first_utm_medium) IN ('cpc', 'paid_search', 'paid_social') THEN 'Paid' WHEN lower(first_utm_medium) IN ('email', 'outbound', 'direct_mail', 'event') THEN 'Outbound' ELSE 'Unknown' END AS channel FROM read_csv_auto('deals.csv') ) SELECT channel, count(*) AS deals, sum(amount) AS pipeline, sum(amount) FILTER (WHERE stage = 'Closed Won') AS won_revenue, round(100.0 * count(*) FILTER (WHERE stage = 'Closed Won') / nullif(count(*) FILTER (WHERE stage IN ('Closed Won', 'Closed Lost')), 0), 1) AS win_rate_pct, round(100.0 * sum(amount) / sum(sum(amount)) OVER (), 1) AS pipeline_share_pct FROM deals GROUP BY channel ORDER BY pipeline DESC; 

How it works:

  • The CASE puts every medium into one channel. A missing medium falls through to Unknown, which shows you how much pipeline has no source.
  • FILTER (WHERE ...) counts only the rows you want inside one aggregate, so won revenue and win rate sit in the same row as total pipeline.
  • Win rate divides wins by closed deals only (won plus lost), so open deals don't drag it down. nullif avoids dividing by zero for a channel with nothing closed yet.
  • sum(sum(amount)) OVER () is the total pipeline across all channels, so each row gets its share of the whole.

Decide your mapping before you run it

The mapping is a business decision, not a technical one. A few common calls:

  • Direct (none): usually inbound. Someone typed your URL or used a bookmark.
  • Email: a nurture email to someone who opted in is closer to inbound; a cold sequence is outbound. If you use both, tag them with different mediums (for example nurture and outbound).
  • Events: outbound if you booked the meetings with outreach before the show.

Write the mapping down and keep it the same every quarter, or the trend lines mean nothing.

A real example

Narrative Brand Labs' success stories show why separate rows matter. For Aprios, the inbound website pipeline reached $6,675,000. Within that, one $1.2M RFQ came from direct traffic and a $1M RFQ came from paid search. Lumped together as "website", you'd never know which source to fund next. One company's results don't predict another's.

Key facts

  • Channel reporting needs a first-touch source stored on every deal.
  • A CASE mapping from utm_medium to channel keeps the logic in one place.
  • Count win rate on closed deals only.
  • Watch the Unknown row: it is the pipeline your tracking misses.

FAQ

Can I do this in a spreadsheet instead?
Yes. Add a channel column with a lookup table, then use SUMIFS for pipeline and COUNTIFS for deals and wins. SQL is easier to rerun on every new export.

Should I report first touch or last touch?
Both if you can. First touch shows which channel creates demand; last touch shows which one converts it. Store both on the deal.

What if most of my pipeline lands in Unknown?
Fix tracking before you move budget. Capture UTMs on forms and copy them to the deal when it is created.

If you want a wider view of what's working across your go-to-market, the free GTM Assessment scores five dimensions in 25 questions.