How to track RevenueCat revenue by traffic source
By Devendra Variya, co-founder of Virling. Published 2026-11-16, updated 2026-12-01.
To track RevenueCat revenue by traffic source, give each web visitor an ID, store that ID on the RevenueCat customer before they buy, and join each purchase back to the visits that came before it. RevenueCat knows which app user paid, for which product, in which store. It does not know which ad, post or search sent them to you.
That gap matters most when you run a web funnel: people read a post or click an ad, land on your site, sign up or buy there, and only later open the app. This post walks through that path in plain words, and is honest about the purchases no tool can tie to a visit.
The web-to-app path
A subscriber who came through your site takes one of two roads:
- They buy on the web. A web paywall on your site sells the subscription, and they open the app afterwards with the same account.
- They sign up on the web, then buy in the app. They create an account on your site, install the app, log in, and subscribe through the App Store or Google Play.
On both roads there is a moment when you know two things at once: the visitor ID in their browser and the app user ID RevenueCat uses for them. That moment is where the link is made. Everything below is about catching it.
Step 1: set a visitor ID
Your analytics script sets one first-party ID per visitor and remembers the first source: referrer, UTM tags or direct. Put the script on every page a buyer passes through, including the paywall and the signup page, not only the landing page.
Step 2: store the ID on the RevenueCat customer
RevenueCat customers carry attributes, so the ID can live on the customer and travel with every purchase they make. Set an attribute named virling_vid before the purchase, in one of two ways:
- From your app with the RevenueCat SDK's
setAttributes, once you have the visitor ID for that person - From your server when the person signs up on your site, using the cookie from that request and their app user ID
The server call looks like this:
await fetch(`https://api.revenuecat.com/v2/projects/${projectId}/customers/${appUserId}/attributes`, {
method: "POST",
headers: { authorization: `Bearer ${process.env.REVENUECAT_SECRET_KEY}`, "content-type": "application/json" },
body: JSON.stringify({ attributes: [{ name: "virling_vid", value: req.cookies.virling_vid }] }),
});The secret key in that call can change customer data, so it lives on your server only, never in the app, and it should not be the key your analytics tool holds.
Timing is the part people get wrong. The ID has to be on the customer before the purchase happens, because the purchase event carries the attributes the customer had at that moment. Set it at signup, not after checkout.
Step 3: receive purchases as they happen
RevenueCat sends purchases, renewals and cancellations to a webhook. Each event carries the customer's attributes, so the visitor ID arrives with the purchase. Check a shared secret on every delivery so nobody else can post fake purchases to it.
Step 4: join purchases to visits
Match each purchase's ID to that visitor's earlier visits and credit one of them with a rule you keep fixed (see first touch or last touch). Purchases with no ID have no visit to join, so they show as Unattributed.
Step 5: handle trials, renewals and refunds
App subscriptions often start with a free trial, and the money only shows up at the first renewal. Record the trial start with its visitor ID and hand that channel to the first paid renewal, or a channel that brings trials will look like it brings nothing (see trial-to-paid conversion by traffic source). Each later renewal should inherit the same channel rather than be matched again. Mark refunds against the payment they belong to, or a channel will look better than it is.
Step 6: report revenue per channel
Group the joined purchases by channel and divide by visitors to get revenue per visitor. That is the table that tells you which ad or post pays for itself.
What cannot be attributed
Some revenue never had a visitor ID behind it, and no web analytics can explain it:
- Installs with no web visit: people who found the app by searching the store, from a store listing, or from a friend, and never touched your site
- People who visited your site but then made a new account in the app, so their app user ID was never linked to the visit
- Purchases made before the attribute was set
Count them in total revenue, but label them Unattributed rather than guessing a channel. That is the honest answer: the visit did not happen, or was never linked, so there is nothing to credit. If most of your subscribers start in the store, the Unattributed share will be large, and that tells you how much of your growth the web funnel explains.
A worked example: four sources in one month
Example data, made up to show the method. An imaginary habit tracker app sells a $13 monthly subscription through RevenueCat, with a 7-day free trial, and runs a web funnel next to its store listing. The table shows one month of first payments, joined the way the steps above describe. Revenue is the first payment only, before store fees. Before you send traffic to the funnel, run each tagged ad and newsletter link through the UTM checker so the visits arrive with the right source.
| Source | Web visits | App purchases matched to a visit | Trials converted | Revenue |
|---|---|---|---|---|
| Organic search to a blog post | 2,317 | 27 | 19 | $351 |
| Paid social ad | 1,469 | 17 | 12 | $221 |
| Newsletter link | 583 | 11 | 6 | $143 |
| Unattributed: found the app in the store | None | 0 of 34 purchases | 21 | $442 |
| Total | 4,369 | 55 of 89 purchases | 58 | $1,157 |
The 34 purchases in the last row came from people who searched the store or heard about the app from a friend and never visited the site, so no customer in that group has a virling_vid attribute and there is no visit to join. They stay in total revenue, and the row says so instead of spreading $442 across the three web sources. Of the $1,157, the web funnel explains $715. Per visitor, organic search and the paid ad both bring about $0.15, and the newsletter brings about $0.25 from far fewer visits. Trials converted counts the first payments that followed a free trial; the other 31 of the 89 were bought without one.
What goes wrong
- Setting the attribute after the purchase, so the purchase arrives with no visitor
- Running the script on the landing page but not on the signup page or paywall, so the ID is never read where the account is made (see RevenueCat web paywall attribution)
- Giving the server key more access than it needs
- Counting the trial start as the sale, or ignoring refunds, which overstates a channel
Doing it with Virling
Virling does steps 3 to 6 for you: connect RevenueCat once and it adds the webhook, joins each purchase to a visit, and reports revenue per channel, trials and refunds included. Steps 1 and 2 stay with you: run the script on your paywall and signup pages, and set virling_vid before the purchase.
On a page that runs the script, window.virling.vid() returns the visitor ID for your app or paywall code, and the virling_vid cookie holds it for your server. Key permissions, what is imported and what stays Unattributed are on the RevenueCat integration page.
Frequently asked questions
Can RevenueCat show which ad or post led to a subscription?
Not on its own. RevenueCat records the customer and the purchase, not the web visit. You need to store a visitor ID on the customer as an attribute and join it to your analytics.
What happens to installs with no web visit?
Nothing links them to a web channel. Keep people who found the app in the store, and never came through your site, in total revenue under Unattributed instead of spreading them across your channels.
What if someone signs up on the web, then makes a new account in the app?
Their purchase arrives under a different app user ID than the one that holds the visitor ID, so it cannot be joined. Send people from the web to log in to the app with the account they just made, so RevenueCat sees the same app user ID.
See your RevenueCat revenue by traffic source
Virling is open source under AGPL. Self-host it free, or use the hosted version with a 14-day free trial. It connects to Stripe, Paddle, Shopify, WooCommerce, Polar, LemonSqueezy, Dodo, Creem and RevenueCat.