Stripe pricing table UTM tracking: see which source sold
By Devendra Variya, co-founder of Virling. Published 2026-11-22, updated 2026-11-28.
A Stripe pricing table is an embed on your own page, not a link, so the Virling script cannot tag it the way it tags Payment Links. To see which channel brought each sale from it, set the table's client-reference-id attribute to the visitor ID before the table loads. Stripe copies the value onto the Checkout Session, and Virling uses it to credit the visit. That is a few lines of HTML in place of the tag Stripe gave you.
How the pricing table embed works
Stripe gives you two tags: a script from js.stripe.com/v3/pricing-table.js and a <stripe-pricing-table> element with your pricing-table-id and publishable-key. The script draws the plans inside a frame from js.stripe.com. When the buyer picks a plan, the table creates a Checkout Session and sends the whole tab to Stripe Checkout.
That Checkout Session drops the UTM tags and the referrer of your page, just as a Payment Link's does; why is explained in what Stripe keeps and drops.
The client-reference-id attribute
Besides the table ID and key, the element takes three optional attributes: client-reference-id, customer-email and customer-session-client-secret. There is no attribute for metadata, so client-reference-id is the only one that can carry a visitor ID.
- Where it ends up. Stripe passes it to the Checkout Session's
client_reference_id, with an underscore, which also arrives in thecheckout.session.completedevent. - What it accepts. Letters, digits, dashes and underscores, up to 200 characters. Stripe drops other values without an error and the table still works, so a bad value only shows up as a missing ID (Stripe pricing table docs). A Virling visitor ID is a
vfollowed by lowercase letters and digits, so it always fits. - Who can see it. The attribute is in your page's HTML, so anyone can read it. Stripe warns against putting secrets in it; a visitor ID is a random string and gives nothing away.
Does the Virling script fill it by itself?
No. The script looks for <a href> links to buy.stripe.com and a few other checkout hosts, and adds the visitor ID to their URL. A <stripe-pricing-table> element has no href, and the plan buttons live inside Stripe's frame, where no script from your page can reach. So you pass the ID yourself, from window.virling.vid(), as in step 2 below.
Pass the visitor ID in three steps
Step 1: load the Virling script before the table. It goes in the <head>, with defer, as the app shows it:
<script defer src="https://app.virling.com/v.js" data-site="yourdomain.com"></script>
Once it has run, window.virling.vid() returns the ID of the current visitor, the same one its visits are stored under.
Step 2: pass the visitor ID to the table. Replace the <stripe-pricing-table> tag Stripe gave you with this, using your own table ID and publishable key:
<script async src="https://js.stripe.com/v3/pricing-table.js"></script>
<div id="pricing"></div>
<script>
addEventListener("DOMContentLoaded", () => {
const table = document.createElement("stripe-pricing-table");
table.setAttribute("pricing-table-id", "prctbl_...");
table.setAttribute("publishable-key", "pk_live_...");
const vid = window.virling?.vid?.();
if (vid) table.setAttribute("client-reference-id", vid);
document.getElementById("pricing").append(table);
});
</script>A defer script runs before DOMContentLoaded, so the visitor ID is ready even on a first visit, and the table is created with the attribute already set. If you load the Virling script another way, such as from a tag manager, make sure it has run before this snippet.
Step 3: connect Stripe. Paste a read-only restricted key into Virling; the Stripe docs list the permissions it needs and the order in which Virling looks for the visitor ID.
customer-email and logged-in users
On a pricing page for people who are already signed in, you may want Checkout to know who they are. The table offers two ways, and neither needs client-reference-id:
customer-emailfills in the email on the payment page, through the Checkout Session'scustomer_email. Set it next toclient-reference-idin the snippet, from the email of the signed-in user.customer-session-client-secretattaches an existing Stripe customer. Your server creates a Customer Session for that customer with the pricing table component enabled, and you set itsclient_secreton the element. Stripe gives you 30 minutes to render the table with it and 30 more to pay.
Stripe's docs suggest client-reference-id for your own user ID, but then it cannot hold the visitor ID, and Virling reads your user ID as one, finds no visit, and the sale is Unattributed. Keep the visitor ID there and find the user through the Stripe customer or the email instead. Two things to know about the Virling side:
- With an existing customer attached, a later purchase by the same customer is counted as a renewal and keeps the channel of their first payment (Renewals).
- If you send an
identifyevent with the user's email at signup, a payment that arrives with no visitor ID at all can still be matched by email. A payment whoseclient_reference_idholds your own user ID is not matched this way, because it already has an ID.
Check that it worked
- Connect a restricted key that starts with
rk_test_, and put the table ID andpk_test_key of a test-mode pricing table in the snippet. - Open a private window and visit the page that holds the table through a tagged link, such as
https://yourdomain.com/pricing?utm_source=test&utm_medium=email. - In your browser's developer tools, find the
<stripe-pricing-table>element. Itsclient-reference-idstarts withvand matcheswindow.virling.vid()in the console. - In the same window, pick a price and pay with one of Stripe's test cards. The Checkout Session has the same value in
client_reference_id. - Wait a minute for the next sync, then open the payments list at
/app/yourdomain.com/payments. The payment shows thetestsource and the Email channel of your tagged visit instead of Unattributed.
Use a new customer for each test, because a later payment by the same customer is a renewal and keeps the first payment's channel. A site has one Stripe connection, and test payments stay in your reports after you replace the key with a live one.
When a pricing table sale has no source
- The ID was not ready. If your snippet runs before the Virling script,
window.virlingis not there yet and the table loads without an ID. client-reference-idholds another value. A table can carry only one, so your own user ID leaves no room for the visitor ID.- No cookie. In cookieless mode, or before consent when Until consent is on,
window.virling.vid()returns nothing and the snippet leaves the attribute off.
A pricing table, a Payment Link and a Checkout Session all end in a Stripe Checkout Session. What differs is where you put the visitor ID:
| Checkout | What carries the ID | Who sets it | If you already use that field |
|---|---|---|---|
| Pricing table | client-reference-id on the element, copied to client_reference_id on the Checkout Session | Your snippet, as in step 2 | No room for the visitor ID, so the sale is Unattributed |
| Payment Link | client_reference_id on the buy.stripe.com link, copied to the Checkout Session | The Virling script, on a normal <a href> link on a page that runs it | The script keeps your value, so the sale is Unattributed |
| Checkout Session | client_reference_id or metadata.virling_vid on the session | Your server, from the virling_vid cookie | Put the ID in metadata.virling_vid instead |
If you sell with Payment Links instead, the script does all of this for you; see Stripe Payment Link UTM tracking. If you create Checkout Sessions on your server, you pass the ID in the session; see Stripe Checkout UTM parameters, or Stripe embedded checkout UTM tracking when the form sits on your page. Every other Stripe checkout is covered on the Stripe integration page. If your checkout is not on Stripe, or is on another domain you own, see cross-domain checkout.
Frequently asked questions
Does Stripe record which page my pricing table was on?
No. The table opens Stripe Checkout, and the Checkout Session has no field for the UTM tags or the referrer of the page that held the table. To keep the source, pass an ID in the client-reference-id attribute and record the visit on your side.
Does the Virling script tag a pricing table by itself?
No. The script adds client_reference_id to buy.stripe.com links, but a pricing table is not a link. Set client-reference-id on the stripe-pricing-table element from window.virling.vid(), as in the snippet on this page.
What if I already use client-reference-id for my own user ID?
A pricing table has one client-reference-id and no metadata attribute, so it can hold only one of the two. If it holds your own ID, Virling has no visitor ID for that sale and it shows as Unattributed.
Why is a pricing table sale missing its source?
The visitor ID was not set when the table loaded: the Virling script was not on the page, it loaded after your snippet ran, it runs in cookieless mode, or client-reference-id holds another value. Check the attribute in your browser's developer tools.
Can I prefill the email with customer-email and still track the source?
Yes. customer-email and client-reference-id are separate attributes on the stripe-pricing-table element, so set both: the email fills in the payment page and the visitor ID still reaches the Checkout Session. Only client-reference-id carries the source.
See which campaigns bring Stripe revenue
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.