virling Pricing Self-host Demo Changelog Agencies GitHub Start free trial
integrations / stripe for saas

See which channel brings your Stripe subscribers.

Built for SaaS teams that bill through Stripe Billing, trials included. Every subscription, the charge that ends a trial and each renewal after it are credited to the channel the customer first came from, so you judge channels by paying customers rather than signups. AGPL open source: use the hosted service or run it yourself.

Start free trial See the demo

Stripe holds the charge, the customer and the invoice. It has no record of the search result, post or ad that sent that customer to your pricing page, and a renewal in month six involves no visit at all. Virling fills the gap with a restricted key that can only read.

What you get

  • A channel for every subscriber. The first charge of a Stripe customer is matched to that visitor's earlier visits. Out of the box, credit goes to the most recent visit within 90 days that was not Direct; for long B2B evaluations, switch to first touch or a 365-day window.
  • Trial conversions credited to the visit before signup. A Checkout Session in subscription mode that completes with a total of 0 is read from its checkout.session.completed event as a trial start. It never adds revenue, a payment or a customer; it only lets the first real charge, which carries no visitor ID, inherit the visits from before the trial.
  • Renewals and upgrades on the original channel. Charges whose invoice has billing reason subscription_cycle or subscription_update copy the channel, referrer, campaign, landing page, country and device of the customer's first charge, looked up by Stripe customer ID.
  • Subscribers who stay, per channel. Retention sorts customers by the channel of their first charge and shows still paying, net LTV and 30-day churn, with subscription status and prices read from Stripe once an hour for MRR.
  • Channels and Time to pay. Rank channels by revenue per visitor instead of visits, and check the median gap between first visit and first charge before you decide a channel has failed.
  • Signup and trial goals. Call virling("goal", "signup") and virling("goal", "trial") from your app. Both appear in each payment's journey, and signup feeds the funnel on the Goals card.

Set it up

  1. Create the site. Use + Add a site, type your domain, for example yourproduct.com, and pick its timezone.
  2. Tag the marketing site and the app. Put the script tag in the <head> of both. The virling_vid cookie lives on the registrable domain, so a visitor on yourproduct.com keeps the same ID on app.yourproduct.com. Keep cookieless mode off.
  3. Connect Stripe with a restricted key. The scopes it needs are listed in the next section. Paste the rk_live_ key under payments; Virling imports 90 days of charges, then looks for new ones every minute.
  4. Send the visitor ID with each checkout. Your server passes the virling_vid cookie when it creates a Checkout Session. Payment Links and the Billing portal are covered below.
await stripe.checkout.sessions.create({
  mode: "subscription",
  client_reference_id: req.cookies.virling_vid,
  // ...
});

For a longer walkthrough, see how to track Stripe revenue by traffic source. MRR by acquisition channel explains how channel credit adds up to recurring revenue, the trial to paid calculator compares trial conversion by channel, and the guide to revenue analytics tools sets channel revenue tools apart from MRR and churn dashboards.

Checkout Sessions, Payment Links and the Billing portal

A customer can start or change a Stripe subscription in three places, and each one reaches Virling in its own way.

  • Checkout Sessions. Set client_reference_id to the visitor ID, or metadata.virling_vid if that field already holds your own user ID. Virling looks at the charge's metadata first, then its PaymentIntent's, then the Checkout Session that created it. A session that charges nothing up front is also how a free trial is seen: a trial created straight through the Subscriptions API, without Checkout, leaves no trial start to read, so its first charge is usually Unattributed.
  • Payment Links. No server code. When someone clicks a buy.stripe.com link on a page that runs the script, it appends client_reference_id with their visitor ID, and Stripe copies it onto the session. A link that already sets client_reference_id is left alone. The same link sent in an email, printed as a QR code or served from a custom domain arrives without an ID and lands in Unattributed.
  • Billing portal upgrades. A plan change in Stripe's customer portal never passes through your site or Checkout, so it has no visitor ID, and it does not need one. When Stripe invoices the change at once, the charge has billing reason subscription_update; when the proration waits for the next cycle, it rides on a subscription_cycle invoice. Both are renewals that keep the channel of the customer's first charge.
  • Restricted key scopes. Give the key Read on Charges, Checkout Sessions, Customers, Events, Invoices, Subscriptions and PaymentIntents, and None on the rest. Charges are the payments; Events bring refunds, lost disputes and trial checkouts; Invoices give the billing reason; Checkout Sessions and PaymentIntents hold the visitor ID; Subscriptions give the hourly status. A secret key (sk_live_) is turned away, and a key without Charges or PaymentIntents fails to connect with a list of what it lacks.

Example: one Stripe subscriber

This customer and these numbers are made up, to show how each Stripe charge is credited.

DayWhat Stripe recordsWhat Virling shows
0Nothing yet: the visitor finds your comparison page through a Google searchA visit in the Organic search channel
2The visitor starts a 14-day trial of the $29 a month plan through a Checkout Session your server created with client_reference_id. Nothing is charged, and checkout.session.completed reports a total of 0A trial start tied to the Organic search visit. No revenue, no payment and no customer
16The trial ends and Stripe charges $29 on an invoice with billing reason subscription_cycle. The charge has no visitor ID of its ownA $29 payment marked as a renewal, credited to Organic search through the trial start
30In the Billing portal the customer moves to the $49 plan, and Stripe invoices a prorated $10 at once with billing reason subscription_updateA $10 payment marked as a renewal, credited to Organic search by customer ID
46The next monthly invoice charges $49, billing reason subscription_cycleA $49 renewal on Organic search, which now has $88 from this customer, all traced to the visit on day 0

How each Stripe charge is credited

Each row is a charge or an event as Stripe sends it, and what Virling does with it.

Stripe sendsCreditShown on
First chargeGoes to a visit of the visitor ID from client_reference_id or metadata.virling_vid; by default the latest visit in the past 90 days that was not DirectChannels, Payments, New customers and Retention; Time to pay once a channel has three first charges
Charge after a free trialInherits the visits before the trial, when the trial began in Checkout after Stripe was connected. Stripe bills it with billing reason subscription_cycle, so it counts as a renewalChannels and Payments as a renewal. Left out of New customers, Time to pay and the Retention customers; the trial start itself never appears as a payment
RenewalBilling reason subscription_cycle, or any later charge by the same customer, keeps the first charge's channelChannels and Payments as a renewal, plus net LTV on Retention
Upgrade or plan changeBilling reason subscription_update, from the portal or your own code, keeps the first charge's channelTreated like a renewal
Refund or disputeReduces its charge, on the charge's own date. A dispute lost after you connect counts as a refund; open or won disputes change nothingRefunded on Channels, the refunded filter on Payments, and refund rate and net LTV on Retention
CancellationNo credit moves. Earlier charges keep their channel, and a customer who comes back under the same customer ID keeps the original oneDrops out of Still paying and MRR. Status is read hourly, and a cancellation at period end counts as paying until the period ends

See your Stripe subscriptions by first channel

For founders who run subscriptions on Stripe Billing. The code is AGPL: run it on your own server at no cost, or let us host it, free for the first 14 days.

Start free trial See the demo

Your first month of Stripe data

  1. Channels, with renewals in mind. Revenue on Channels counts renewals, so New customers is the figure for what this month won. The matched revenue line tells you how much has a visit behind it; charges imported from before the script are Unattributed, so the first weeks look thin.
  2. Retention, once customers age. 30-day churn only covers customers whose first charge is between 30 and 60 days old. Trial customers are missing from the Retention customers because Stripe bills their first charge as a renewal, so follow them on Channels and Payments.

Three conclusions to wait on:

  • A channel with no charges yet. Its trials may still be running. Wait until Time to pay shows its median has passed.
  • A channel that leads on one annual plan. Open Payments and count the charges behind it.
  • Churn from a small group. Below 20 customers or 5 still paying, Retention writes no headline; take the hint.

Before you rely on it

  • Trial starts are read from the day you connect Stripe. Earlier trials are invisible, and their first charges are usually Unattributed.
  • The first import reaches back 90 days. Subscriptions that began earlier have their renewals mostly Unattributed until new customers take their place.
  • A charge without a customer ID cannot be tied to a first charge, and one without a visitor ID still counts as revenue, under Unattributed.

Open source

The code is on GitHub under AGPLv3, and the self-hosted binary has every feature the hosted service has. Tested on 2026-10-31 in a container held to one vCPU and 1 GB of RAM, it took in 100,000 pageviews at 2,829 per second with zero failures and a p99 of 34 ms, using 157 MB of memory afterwards.

Questions about Stripe for SaaS

Which channel brings my Stripe subscribers?

Give Virling a restricted key with read access and send the visitor ID into Checkout. Each customer's first charge is credited to the visits that came before it, and every renewal inherits that channel, so Channels and Retention show which sources bring subscribers who keep paying.

How are Stripe renewals attributed?

Charges on invoices with billing reason subscription_cycle or subscription_update are renewals. They copy the channel, referrer, campaign and landing page of the customer's first charge, found by Stripe customer ID.

Are upgrades in the Stripe Billing portal credited?

Yes. A plan change in the customer portal is either charged at once with billing reason subscription_update or added to the next subscription_cycle invoice. Either way it keeps the channel of the customer's first charge, with no visitor ID needed.

What about free trials on Stripe?

Virling reads a trial start from a checkout.session.completed event in subscription mode with a total of 0. The trial start adds no revenue, payment or customer. When the first charge arrives without a visitor ID, it is credited to the visits before the trial. Only trials started through Checkout after you connect Stripe are seen.

Does Virling need write access to Stripe?

No. The restricted key needs Read on Charges, Checkout Sessions, Customers, Events, Invoices, Subscriptions and PaymentIntents only. Secret keys are refused.

What about Stripe subscriptions that began before Virling was connected?

The first import covers 90 days of charges. If a subscription's first charge is older, its earliest charge in Virling stands in for it; that charge rarely has a visit, so the renewals are usually Unattributed, and so is a first charge from before the script was installed. They still count as revenue, but a customer whose earliest charge in Virling is a renewal is not in Retention.

More detail: the SaaS setup guide, the Stripe docs page and how renewals are credited.

Start free trial