virling Pricing Self-host Demo Changelog Agencies GitHub Start free trial
blog / 2026-11-18

Dodo Payments UTM tracking: pass source data through checkout

By Devendra Variya, co-founder of Virling. Published 2026-11-18, updated 2026-11-27.

A Dodo Payments checkout starts on checkout.dodopayments.com, so the UTM tags on your landing page never reach the payment. The fix is one metadata key, virling_vid: static payment links get it as a metadata_virling_vid query parameter, which the Virling script adds on click with no code, and checkout sessions get it in the metadata object your server sends to the API. Virling then reads metadata.virling_vid back from each payment and credits it to that visitor's visit.

Where the source gets lost on Dodo checkout

Dodo Payments stores who paid, for which product and how much, plus whatever metadata you hand it. It drops the visit in two places:

  • Payment links. The buyer clicks a checkout.dodopayments.com/buy/... link, often several pages after landing, and that URL says nothing about how they found you.
  • Checkout sessions. Your server creates the session, and only the cookies on that request know which visitor is buying.

Why a visitor ID works better than copying UTM tags into metadata is covered in the Paddle UTM post; it applies to Dodo unchanged. How Virling picks the visit that gets the credit is in how attribution works.

Step 1: run the script on every page with a buy link

The Virling script sets a first-party virling_vid cookie for each visitor and records their visits under it. A buy link only gets the ID if the page it sits on loads the script, so add it to pricing, product and docs pages, not just the home page.

Step 2: static payment links need no code

Dodo turns any query parameter that starts with metadata_ on a payment link into a metadata field on the payment; its own example is metadata_orderId=123 (Dodo integration guide). So metadata_virling_vid on the link becomes metadata.virling_vid on the payment.

With Virling you do not add it by hand. Keep the link as a normal <a href> on a page that runs the script, and when a visitor clicks it, the script appends metadata_virling_vid=<visitor ID> unless the link already has one:

<a href="https://checkout.dodopayments.com/buy/pdt_...">Buy now</a>

Other link parameters, such as redirect_url for the page buyers land on after paying, stay as they are. Selling ebooks, templates or courses this way? Dodo Payments for digital products shows those sales by channel and campaign.

Step 3: set metadata on checkout sessions

When your server creates a checkout session through the API, copy the virling_vid cookie from the incoming request into metadata:

const session = await client.checkoutSessions.create({
  product_cart: [{ product_id: "pdt_...", quantity: 1 }],
  return_url: "https://yourdomain.com/thanks",
  metadata: { virling_vid: req.cookies.virling_vid },
});
// Send the customer to session.checkout_url

Metadata is a plain key-value object, so you can store your own keys, such as an order ID or utm_campaign, next to it. Virling ignores every key except virling_vid.

Step 4: links built in your own code

If you build a payment link URL in your own code instead of an <a href>, add the parameter yourself, and only when there is a value:

const url = new URL("https://checkout.dodopayments.com/buy/pdt_...");
const vid = window.virling?.vid?.();
if (vid) url.searchParams.set("metadata_virling_vid", vid);
location.href = url.href;

If that code can run before the script has loaded, the value will be empty, so wait for the script first.

What Dodo returns on the payment, and how Virling reads it

After checkout, Dodo redirects the buyer to your return URL with payment_id, status and, for subscriptions, subscription_id, but no metadata (Dodo checkout session docs). The thank-you page is therefore not where attribution happens. Virling reads the payment itself from the Dodo API instead.

Each payment object Virling lists carries the payment_id, total_amount in the currency's smallest unit, currency, customer.customer_id, metadata, subscription_id, refund_status and dispute_status. Virling takes metadata.virling_vid as the visitor and joins it to that visitor's sessions; a payment without it shows as Unattributed.

  • Sync. Succeeded payments from the last 90 days on the first run, then new ones every minute. Each round re-reads the last 30 minutes, so payments that succeed late are not missed.
  • Refunds and disputes. A refund updates the payment it belongs to, and a lost or accepted dispute counts as a full refund.
  • Subscriptions. Virling looks up the subscription's paid payments, and every one after the first paid payment is a renewal that keeps the first payment's channel. A $0 trial start does not count as the first payment. How this works for plans with usage or add-ons is on Dodo Payments SaaS attribution.

The key setup and product filter are in the Dodo Payments docs page, and the overview is on the Dodo Payments integration page.

Test mode walkthrough

Dodo keeps test mode apart from live mode: test API calls go to test.dodopayments.com, and a test checkout session opens on test.checkout.dodopayments.com. Virling tries a new key against live first and test second, so a test mode key works without any switch.

  1. Create a test mode API key in the Dodo dashboard and paste it under Payment connections in site settings.
  2. In a private browser window, land on your site through a URL with tags, for example https://yourdomain.com/?utm_source=test&utm_medium=email, so the script stores a fresh visitor.
  3. From that window, start a test checkout session that your server creates with metadata.virling_vid. A test payment link also works, but add metadata_virling_vid in your own code: the script only rewrites links on checkout.dodopayments.com.
  4. Pay with one of Dodo's test cards.
  5. After the next one-minute sync, the payment appears at /app/yourdomain.com/payments with source test and channel Email.

Pay each test with a different customer email; Dodo payments from a returning customer count as renewals. Switching the connection from the test key to a live key later keeps the test payments in your reports. More checks are in the setup test guide.

Common mistakes

What you seeCauseFix
A test link payment is UnattributedThe script adds the visitor ID to links on checkout.dodopayments.com, not to test linksAdd metadata_virling_vid in your own code, or test with a checkout session
Checkout session payments are UnattributedThe session was created without metadata.virling_vidRead the virling_vid cookie on the request that creates the session, as in step 3
Payments from a link in an email or on another site are UnattributedThe payment link was opened without a visit to your site, so it carries no visitor IDSend people to a page that runs the script, and put the payment link there
Payments from a link built in code are UnattributedThe URL has no metadata_virling_vidAdd the parameter yourself, as in step 4
Your second test payment is credited like the firstDodo saw the same customer, so Virling marked it as a renewalUse another email address for each test
Payments for another product show upOne Dodo account sells more than this site's productsList this site's product IDs under Only these product IDs in site settings. Payments already imported stay
A dispute lost after the import does not lower revenueVirling counts a lost dispute when it reads the paymentUse Replace key to read the last 90 days again
Payments older than your script install are UnattributedNo visitor ID existed when they were paidNothing to do: their revenue still counts, and later payments get a channel

For causes not listed here, the docs page on Unattributed revenue has the full list.

Example: three tagged posts

Example only: the product, its $29 one-time price and every number below are made up. The seller shares three posts in November, each with its own utm_campaign, named with the UTM naming template. There are no refunds, and Unattributed payments are left out.

PostCampaign tagVisitorsSalesRevenueRevenue per visitor
LinkedIn postprice-guide-2026-119006$174$0.19
X postdemo-clip-2026-112,4004$116$0.05
Reddit postbuild-story-2026-115008$232$0.46

Repeat the Reddit post: it brought the fewest visitors and the most sales. The LinkedIn post is worth a second try, since it earned about four times as much per visitor as the X post. The X post had the most visitors and the fewest sales, so change it before you post it again. These are small samples, so look at the next few posts before you drop a channel. In Virling, this is the Campaign tab of the Channels card, covered in revenue by campaign. The full Dodo join, step by step, is in how to track Dodo Payments revenue by traffic source.

Start free trial

Frequently asked questions

Does Dodo Payments record UTM parameters on its own?

Not as attribution. Dodo Payments records the payment, not the visit that led to it. To tie a payment to its source, pass a visitor ID in the payment's metadata and join it to your analytics.

How do I pass metadata through a Dodo payment link?

Add metadata_virling_vid as a query parameter on the checkout.dodopayments.com/buy link. Dodo stores it as the payment's metadata.virling_vid.

How do I add metadata to a Dodo checkout session?

Set metadata when your server creates the checkout session, for example metadata: { virling_vid: req.cookies.virling_vid }, then send the customer to the session's checkout_url.

Do Dodo payment links need code to carry the visitor ID?

No. When a visitor clicks a normal link to checkout.dodopayments.com/buy on a page that runs the Virling script, the script adds metadata_virling_vid with the visitor ID, unless it is already there.

Can I read the visitor ID from the Dodo return URL?

No. Dodo adds payment_id, status and, for subscriptions, subscription_id to the return URL, but not metadata. Virling reads metadata.virling_vid from the payment through the Dodo API instead.

See which campaigns bring Dodo Payments 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.

Start free trial See the demo