revenue attribution9 min read

SaaS Revenue Attribution: Webhooks vs Pixels

Learn how to attribute SaaS MRR, renewals, and refunds accurately using signed Stripe, Paddle, and Polar webhooks joined to 90-day ClickHouse journeys.

Istiak Rayhan
Istiak RayhanCo-Founder & Product Lead, DotCamp & TrimStats
Systems architecture: Documented directly from TrimStats Fastify HMAC webhook verifiers, 90-day ClickHouse join logic, and 13-currency FX normalization.(apps/web/lib/docs/content/revenue-attribution.ts)
Direct answer

Why do signed payment webhooks outperform browser thank-you pixels for SaaS revenue attribution?

Signed server-to-server payment webhooks from Stripe, Paddle, or Polar outperform browser thank-you pixels because ad blockers, closed checkout tabs, and failed redirects never drop transactions. Joining verified webhook payloads to a 90-day ClickHouse visitor journey also reconciles subscription renewals, negative refunds, and multi-currency FX totals automatically via transaction ID deduplication.

Key takeaways
  • Browser conversion pixels miss ad-blocked buyers, abandoned post-checkout redirects, recurring subscription renewals, and refunds.
  • Forwarding window.trimstats.attribution() into checkout metadata links signed Stripe, Paddle, or Polar webhooks back to referrers, UTM campaigns, and landing pages.
  • First-touch attribution credits the discovery channel that introduced the buyer, while last-touch credits the closing touchpoint prior to checkout.
  • Revenue per Visitor (RPV) exposes high-converting comparison and pricing pages that raw pageview counts hide.

Why client-side conversion pixels fail for SaaS revenue

Pageviews and signup counts are vanity metrics unless you can tie them to net collected revenue. A viral engineering article can bring 15,000 developers to your site and convert two customers, while a quiet competitor comparison page with 400 visits closes $10,800 in annual subscriptions.

Most web analytics tools try to measure revenue by firing a client-side JavaScript snippet on /thank-you after checkout. For subscription software, client-side revenue pixels fail systematically in five ways:

Failure ModeClient-Side Thank-You PixelSigned Server Payment Webhook
Ad blockers & Brave ShieldsDrops 15% to 45% of developer buyers100% captured server-to-server
Closed tab before redirectTransaction lost permanentlyRecorded when payment settles
Monthly or annual renewalsInvisible (no browser visit)Tracked as subscription_renewal
Partial or full refundsNever subtracted from channel totalsRecorded as negative refund
Duplicate page reloadsInflates revenue unless custom dedupedIdempotent via external_tx_id

When marketing reports disagree with Stripe or Polar net revenue by 25% to 40%, founders stop trusting attribution dashboards and revert to guesswork.

Seeded demo workspace
TrimStats Revenue Attribution dashboard showing $32,753 attributed revenue, 559 orders, $1.21 revenue per visitor, and top revenue referrers and landing pagesTrimStats Revenue Attribution dashboard showing $32,753 attributed revenue, 559 orders, $1.21 revenue per visitor, and top revenue referrers and landing pages
Toggle between 90-day first-touch and last-touch models at query time to inspect exact revenue per referrer, UTM campaign, and landing page.

Architecture of server-verified payment-webhook attribution

Reliable SaaS revenue attribution splits the job cleanly across two layers: lightweight browser context capture before checkout, and cryptographically signed server-to-server settlement after payment.

Step 1: Capture the attribution snapshot before checkout

Inside TrimStats t.js (1.96 KB gzipped), window.trimstats.attribution() returns a flat JSON snapshot containing { vid, uid, ref, lp, utm_source, utm_medium, utm_campaign }. Right before redirecting a customer to Stripe Checkout, Paddle Billing, or Polar.sh, forward that snapshot to your backend:

const attribution = window.trimstats?.attribution?.() ?? {};

await fetch('/api/checkout', {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({ priceId: 'price_growth_monthly', attribution }),
});

Your checkout route attaches that object inside provider metadata (for example Stripe metadata.trimstats and subscription_data.metadata.trimstats, or Paddle custom_data). Attaching it to subscription_data.metadata ensures every future recurring renewal invoice inherits the acquisition metadata automatically.

Step 2: Verify raw-byte signatures and join in ClickHouse

When payment settles, Stripe, Paddle, Polar, or your custom billing server sends a signed HTTP webhook directly to POST /v1/webhooks/{provider}/{siteId} on the TrimStats collector. The Fastify ingestion worker verifies the raw request bytes against your encrypted signing secret (including replay-timestamp validation) before writing to ClickHouse.

Seeded demo workspace
TrimStats verified Stripe, Polar, and Paddle webhook panel next to a chronological customer timeline joining a Hacker News entry to a $290 Stripe subscriptionTrimStats verified Stripe, Polar, and Paddle webhook panel next to a chronological customer timeline joining a Hacker News entry to a $290 Stripe subscription
Server-verified payment events merge directly into each buyer timeline alongside pageviews, active dwell time, and custom events.

Next, the collector resolves vid (fp:{siteId}:{vid}) or uid (uid:{siteId}:{uid}) and queries ClickHouse across the previous 90 days of pageview history for that visitor. Even if the visitor browsed in strict cookie-less mode or cleared browser storage before buying, TrimStats falls back automatically to the ref, lp, and utm_* fields carried inside the webhook metadata.

TrimStats technical lookback windows across attribution and journey tables

Verified ClickHouse lookback limits in days (apps/web/lib/content/facts.ts)

days
Cookie-less same-day hash
1 day
Multi-step funnel max window
30 days
Webhook ClickHouse attribution join
90 days
Visitor timeline max lookback
730 days

A 90-day ClickHouse webhook lookup covers long B2B trial and procurement cycles while keeping query latency sub-second.

Methodology: Exact production query limits verified from packages/shared/src/schemas.ts and apps/web/lib/content/facts.ts.

View chart data table
LabelWindow length
Cookie-less same-day hash1 day
Multi-step funnel max window30 days
Webhook ClickHouse attribution join90 days
Visitor timeline max lookback730 days

First-touch vs last-touch attribution for multi-session buyers

SaaS purchases rarely happen in a single tab. A typical engineering lead discovers your product through a Hacker News discussion on Tuesday, reads documentation via Google Search on Friday, discusses pricing with a cofounder over the weekend, and types your domain directly into Chrome on Monday morning to upgrade.

Under last-touch attribution, Direct receives 100% of the revenue credit for that $290 subscription, making top-of-funnel editorial posts and community launches look unprofitable. Under first-touch attribution, Hacker News and the original /blog/script-benchmark landing page receive credit for originating the buyer.

How first-touch vs last-touch attribution shifts credit across SaaS channels

Illustrative 30-day attributed revenue split in USD across acme.dev acquisition channels

USD
First-touch (90d)
Last-touch (90d)
How first-touch vs last-touch attribution shifts credit across SaaS channelsLast-touch over-credits Direct visits when buyers return days later to upgrade, whereas first-touch preserves the discovery channels that originated pipeline.03,9807,96011,94015,920$15,920$8,420Hacker News$11,480$10,960Google Organic$8,340$6,180GitHub$4,610$14,790Direct / Brand

Last-touch over-credits Direct visits when buyers return days later to upgrade, whereas first-touch preserves the discovery channels that originated pipeline.

Methodology: Illustrative channel comparison based on the seeded acme.dev 30-day $40,350 top-channel revenue dataset showing multi-session SaaS buying behavior.

Source: TrimStats seeded demo workspace (acme.dev)
View chart data table
LabelFirst-touch (90d)Last-touch (90d)
Hacker News$15,920$8,420
Google Organic$11,480$10,960
GitHub$8,340$6,180
Direct / Brand$4,610$14,790

Neither model is universally right; each answers a different operational question:

  • Use First-Touch (90d) to evaluate content marketing, SEO pillar guides, open-source launches, and top-of-funnel awareness channels.
  • Use Last-Touch (90d) to evaluate high-intent /vs/* comparison pages, retargeting ads, and onboarding upgrade flows.

Because TrimStats preserves the chronological visitor event stream in ClickHouse instead of baking one hardcoded credit rule at ingestion time, you toggle between first_touch and last_touch dynamically in the Revenue dashboard without replaying webhooks.

Connecting top-of-funnel steps to settled payment webhooks

Attribution tells you who sent the buyer; pairing webhooks with multi-step funnels tells you where qualified buyers leak out before paying. In TrimStats, ClickHouse evaluates 2 to 8 ordered conversion steps across up to a 30-day window.

SaaS acquisition-to-payment funnel closing on verified webhook settlement

30-day seeded acme.dev demo cohort across 5 conversion stages

visitors
  1. 1Landing page visit
    12,480 visitors100.0%
  2. 2Viewed /pricing
    3,420 visitors27.4%-72.6% drop
  3. 3Completed signup
    612 visitors4.9%-82.1% drop
  4. 4Started checkout
    384 visitors3.1%-37.3% drop
  5. 5Verified webhook payment
    264 visitors2.1%-31.3% drop

Measuring server-verified payment settlement as the terminal step pinpoints exact checkout drop-off (31.3% between checkout start and paid).

Methodology: Seeded 30-day acme.dev SaaS demo funnel joining browser pageview/event signals with server-verified payment webhooks.

Source: TrimStats seeded demo workspace (acme.dev)
View chart data table
LabelVisitors
Landing page visit12,480 visitors
Viewed /pricing3,420 visitors
Completed signup612 visitors
Started checkout384 visitors
Verified webhook payment264 visitors

When you combine funnel drop-off with opt-in UI Friction Tracking, checkout leaks stop being mysterious. If 31.3% of users who start checkout drop before webhook settlement and /checkout simultaneously flags rage clicks on button#apply-coupon.btn-ghost, engineering immediately knows which broken interaction is costing MRR.

Core revenue KPIs every SaaS team should track per channel

Raw revenue totals favor high-volume channels even when conversion efficiency is poor. Evaluate every referrer, UTM campaign, and landing page using four paired formulas computed directly in TrimStats:

  1. Net Revenue: sum(one_time + subscription_new + subscription_renewal - refunds) normalized to usd_cents across 13 supported FX currencies (USD, EUR, GBP, CAD, AUD, CHF, JPY, INR, BDT, BRL, SGD, SEK, NZD).
  2. Average Order Value (AOV): net_revenue / orders showing which channels attract annual or Scale-tier teams vs entry-tier signups.
  3. Revenue per Visitor (RPV): net_revenue / unique_visitors identifying your highest-leverage landing pages regardless of traffic size.
  4. Visitor-to-Customer Conversion Rate: paying_customers / unique_visitors highlighting intent differences between informational guides and commercial /vs/* pages.

Handling subscription lifecycle edge cases accurately

SaaS billing diverges quickly from one-off e-commerce orders. If an attribution pipeline only handles initial checkout charges, revenue reports drift out of sync with your actual bank ledger within two billing cycles. Four lifecycle scenarios require explicit server-side modeling:

Monthly and annual subscription renewals

When Stripe fires invoice.paid with billing_reason === "subscription_cycle", no browser session occurs. The customer is asleep while Stripe charges their card on file. Because TrimStats reads subscription_data.metadata.trimstats (and looks up historical uid or vid attribution in ClickHouse), renewal revenue credits back to the acquisition channel that originally won the account. Measuring renewal-inclusive net revenue reveals which channels produce sticky, low-churn customers rather than one-month trial tourists.

Partial and full refunds

Disputes and refunds directly change channel ROI. Suppose a paid social campaign drives $4,000 in initial signups, yet $1,800 refunds within 14 days because ad copy over-promised a feature. TrimStats listens for charge.refunded webhooks and records negative refund rows keyed as refund:<charge_id>, automatically lowering net revenue for the originating channel and campaign without requiring manual CSV reconciliation.

Webhook retries and idempotency

Payment gateways retry webhooks aggressively whenever a network timeout or transient 5xx occurs. Without deterministic deduplication, a single $290 invoice can easily appear twice in analytics charts. TrimStats keys every ingested revenue record by external_tx_id, ensuring duplicate webhook deliveries settle cleanly into one ledger-accurate transaction.

Zero-decimal and multi-currency normalization

Global SaaS teams sell in Euros, British Pounds, Japanese Yen, Canadian Dollars, and Brazilian Reais simultaneously. Treating minor currency units uniformly breaks immediately on zero-decimal currencies like JPY, where 10000 represents 10,000 yen rather than 100.00. TrimStats stores the original currency code and raw minor amount alongside a normalized usd_cents column across 13 supported FX currencies so cross-country totals aggregate accurately.

Preventing attribution leaks across subdomains and auth flows

Even with signed webhooks in place, three common application mistakes can break attribution continuity between your marketing site and checkout route:

  1. Losing UTM parameters during signup redirects: When a visitor clicks from /vs/plausible?utm_source=newsletter to /signup and then into an OAuth login redirect, query parameters disappear from the address bar. Because t.js snapshots initial ref, lp, and utm_* values on the first landing page (and persists _ts_attr in localStorage when first-party mode is active), window.trimstats.attribution() retains the original acquisition parameters all the way to checkout.
  2. Splitting marketing and app domains without identify(): If your marketing site runs on trimstats.com and your billing checkout runs on app.trimstats.com, call window.trimstats('identify', userId) immediately after account login and pass client_reference_id: userId to Stripe or Paddle. ClickHouse then bridges pre-signup visits and post-signup payments via the identified user hash.
  3. Forgetting to attach metadata to Customer Portal upgrades: Users who start on a $17 Starter plan and later upgrade to $44 Growth or $134 Scale generate invoice webhooks under the same subscription object. Storing trimstats inside subscription_data.metadata at initial checkout ensures every subsequent upgrade invoice retains full attribution history.

Implementation audit checklist before shipping

Before relying on revenue dashboards for monthly ad spend or content roadmap decisions, run one test checkout in Stripe Test Mode or Polar Sandbox and verify all four links in the chain:

  • Inspect the browser request payload to /api/checkout and confirm attribution contains ref, lp, utm_source, and vid or uid.
  • Inspect the created Stripe Checkout Session and Subscription objects in the Stripe Dashboard to verify metadata.trimstats is populated on both.
  • Confirm the webhook delivery log returns HTTP 200 from /v1/webhooks/{provider}/{siteId} with zero signature verification errors across Stripe (stripe-signature), Paddle (paddle-signature), Polar (Standard Webhooks), or custom HMAC (x-trimstats-signature).
  • Open TrimStats Revenue and Visitors tabs to confirm the test transaction appears under the expected referrer, landing page, currency conversion, and chronological visitor timeline.
  • Trigger a test refund in your sandbox dashboard and confirm TrimStats records the negative refund:<charge_id> offset immediately while keeping order counts and net revenue reconciled.

Ready to wire server-verified payments into your stack? Follow our copy-paste Stripe Revenue Attribution playbook or explore the full Revenue Attribution feature overview.

Frequently asked questions

Why do browser thank-you-page scripts underreport SaaS revenue?
Thank-you-page scripts execute inside the customer browser after checkout redirects. Whenever a developer runs an ad blocker, closes the Stripe tab before redirect finishes, completes an offline invoice, renews automatically next month, or receives a refund, the browser script never runs and analytics diverges permanently from ledger revenue.
Should SaaS teams optimize marketing budgets using first-touch or last-touch attribution?
Use first-touch attribution when deciding which content, SEO guides, Hacker News launches, or outbound campaigns introduce net-new buyers. Use last-touch attribution when evaluating bottom-of-funnel comparison pages, retargeting, or lifecycle emails that close undecided trials.
What happens if a buyer clears browser storage before purchasing?
TrimStats evaluates multiple fallbacks in order: first it joins by external user ID (uid) or first-party visitor ID (vid) across 90 days in ClickHouse, and if neither matches or the site runs strictly cookie-less, it falls back cleanly to the referrer, landing page, and UTM snapshot embedded directly in the checkout webhook metadata.
How does TrimStats prevent duplicate revenue when payment providers retry webhooks?
Every revenue transaction is keyed and deduplicated by its provider external_tx_id (such as a Stripe invoice or checkout ID, or refund:<charge_id> for refunds). Provider retry deliveries are idempotent and never inflate net revenue or order counts.
How are non-USD subscriptions normalized in multi-currency SaaS dashboards?
TrimStats stores both the original transaction currency and minor-unit amount alongside a normalized usd_cents column across 13 currencies (USD, EUR, GBP, CAD, AUD, CHF, JPY, INR, BDT, BRL, SGD, SEK, and NZD), accounting automatically for zero-decimal currencies like JPY.
How do you preserve attribution across a marketing root domain and an app subdomain?
Read window.trimstats.attribution() on your marketing site or pass UTM parameters across the signup CTA into your app session, then call window.trimstats("identify", userId) after login and forward the snapshot into Stripe, Paddle, or Polar checkout metadata so cross-subdomain journeys stay intact.
Does TrimStats charge extra for revenue attribution webhooks on lower plans?
No. Native Stripe, Paddle, Polar, and Custom HMAC revenue attribution webhooks ship on every TrimStats plan starting with Starter ($17/month for 100,000 events) through Scale ($134/month for 5,000,000 events), with zero per-transaction percentage fees.

Sources & references

Istiak Rayhan
Written & verified by
Istiak Rayhan (Co-Founder & Product Lead, DotCamp & TrimStats)

Co-founder and Product Manager at DotCamp LLC and co-creator of TrimStats. Publisher, SEO practitioner, and WordPress product leader building creator tools since 2012.

  • • Co-founder & Product Manager at DotCamp LLC (est. 2019), guiding product strategy for Ultimate Blocks, WP Table Builder, OptimizeCamp, and TrimStats
  • • Full-time publisher and digital marketer since 2012; founder of RoadToBlogging.com and WPLeaders.com
  • • WordPress.org Plugin Developer, Support Contributor, and WordCamp Sylhet 2023 speaker on building WordPress products

Verification standard: Systems architecture: Documented directly from TrimStats Fastify HMAC webhook verifiers, 90-day ClickHouse join logic, and 13-currency FX normalization.

Measure traffic, revenue, and UI friction in 1.96 KB gzipped

Cookie-less by default, powered by ClickHouse, and starting at $17/month for 100,000 monthly events with every feature unlocked.