Discount code attribution: what codes miss and how to cross-check them
By Devendra Variya, co-founder of Virling. Published 2026-11-18.
Discount code attribution credits a sale to whoever owns the code the buyer typed at checkout. It is the default way to measure influencer, podcast and affiliate deals, because it needs nothing on your site. But a code only sees buyers who type it, and it credits its owner wherever the buyer found it. To know which partners really bring paying customers, give each partner a tracked link as well, credit payments to the visit that came before them, and use the code report as a cross-check.
This is written for ecommerce stores and SaaS companies that pay creators, podcasts or affiliates and hand each of them a code.
What a discount code tells you
A code is counted by your store or payment provider when it is used, however the buyer got to checkout. That makes it good at a few things:
- Offline and spoken mentions. A podcast listener who hears the code in the car and types your URL later still shows up against the code. No link, referrer or cookie is needed.
- Buyers on another device. Someone who sees a post on their phone and buys on a laptop days later can still type the code.
- A simple payout rule. Partners understand it, and it is easy to pay commission on.
What a discount code misses
The same rule that makes codes simple makes them wrong in both directions.
- Buyers who saw the partner but typed no code. A follower clicks the link, browses, and pays without the code, or comes back a week later and pays full price. The sale happened because of the partner, but the code report never sees it.
- Codes that leak. Coupon sites and browser extensions collect codes and show them at checkout to anyone. A buyer who came from a search ad, found the code on a coupon site and used it is credited to the partner who never sent them. Leaked codes also cost you the discount on sales you would have made anyway.
- Everyone who did not buy. A code counts orders only. It cannot tell you how many people a partner sent, so you cannot tell a partner with a large audience that never buys from one with a small audience that does.
- Renewals and later purchases. A code is used once. If you sell subscriptions, the code says nothing about who renewed.
Visit-based attribution
The other approach starts from the visit. Each partner gets a link with UTM tags or a partner link. When someone clicks it, the landing page records the source and campaign with a visitor ID. When that visitor pays, the payment is joined to their visits and credited to the channel and campaign that brought them.
This counts every visit a partner sent and which of those visitors paid, with or without a code. It misses people who never click the link, such as a listener who types your plain URL, and buyers who switch devices before paying. Those are exactly the buyers a code catches, which is why the two work best together.
Use links and codes as a cross-check
Virling credits each payment to the visit and channel that came before it, not to the code. It does not read discount codes, so code redemptions stay in your store or payment provider. Put the two reports side by side for each partner over the same range:
- The link brings far more buyers than the code. Most buyers skip the code. Paying commission on codes alone underpays this partner.
- The code is used far more than the link brings buyers. Either buyers reach you another way, which is common for podcasts and spoken mentions, or the code has leaked. Search the code on coupon sites; if it is there, retire it and issue a new one. Coupon site revenue tracking shows how to tell whether those buyers were new.
- Both are close. The partner's audience clicks and uses the code. Either number is a fair measure for them.
To limit leaks, give every partner a unique code, set an expiry date or a use limit, and keep codes out of public pages you control. If you offer free shipping over a set order value instead of money off, work out how much bigger orders must get to cover the shipping.
A worked example
Example data, made up to show the method: five orders in one month for an imaginary store that gives an influencer the code JANE15 with the link campaign jane-doe, and puts the code NEWS10 in its newsletter. The code comes from the store's order report; the visit source comes from Virling.
| Order | Total | Code used | Visit source in Virling | Agree? |
|---|---|---|---|---|
| 1 | $72 | JANE15 | Social, jane-doe | Yes |
| 2 | $46 | JANE15 | Organic search | No, the code was likely found on a coupon site |
| 3 | $54 | NEWS10 | Yes | |
| 4 | $93 | None | Social, jane-doe | No, the buyer clicked the link but skipped the code |
| 5 | $81 | JANE15 | Direct | No, the buyer typed the URL after seeing a story |
The orders total $346. The code report credits $199 to JANE15 and $54 to NEWS10, with $93 under no code. The visit report credits $165 to jane-doe, $54 to Email, $46 to Organic search and $81 to Direct. The newsletter agrees in both. The influencer is $199 by code and $165 by link: order 2 suggests a leak worth searching for, order 4 is a sale a code-only payout would miss, and order 5 is a sale only the code caught.
Set it up with Virling
- Give each partner a tagged link. Put the platform or partner in
utm_source, the kind of deal inutm_medium(such asinfluencer,podcastorreferral), and the partner inutm_campaign, all lowercase with hyphens. Virling's reports group revenue by campaign, so use one campaign value per partner, and if you like, the same name as their code. Do not usecpcoremailas the medium, since those move the visit into the Paid or Email channel. The UTM builder makes the link for you.Or open Partners in Virling and create a partner link, which makes a short link with the partner's name as the source.https://yourdomain.com/?utm_source=instagram&utm_medium=influencer&utm_campaign=jane-doe https://yourdomain.com/?utm_source=devpod&utm_medium=podcast&utm_campaign=devpod-spring
- Add the script. Put the Virling script in the head of every page, with your domain in
data-site. It reads the tags on the landing page and sets the visitor ID. See add the script. - Pass the visitor ID into checkout. Connect your store or payment provider so each order or payment carries the visitor ID. See link checkout to visits and the list of integrations.
- Compare. Pick a range of a few weeks. Open the Campaign tab in the Channels card, or Partners for partner links, and set each partner's revenue next to their code redemptions from your store for the same dates.
For the details of each kind of deal, see influencer revenue tracking, podcast revenue tracking and affiliate revenue tracking. For codes printed on postcards and inserts, see direct mail revenue, and for sale codes that spread over one weekend, see tracking Black Friday sales by channel.
Frequently asked questions
What is discount code attribution?
Discount code attribution credits a sale to whoever owns the code the buyer typed at checkout, such as an influencer, podcast or affiliate. It needs no tracking on your site, but it only counts buyers who enter the code, and it credits the code owner even when the code was found somewhere else.
Are discount codes accurate for tracking influencer or affiliate sales?
Only partly. Codes miss buyers who clicked the partner's link but paid without the code, or came back later and paid full price. They also over-credit when a code leaks to a coupon site and strangers use it. And a code says nothing about how many people visited and did not buy.
Coupon code vs UTM tracking: which is better?
Use both. A code catches buyers who reached checkout without clicking any link, such as a podcast listener who typed your URL. A UTM link counts every visit a partner sent and which of those visitors paid, code or not. Comparing the two for one partner shows whether the code has leaked or followers skip it.
Does Virling track discount codes?
No. Virling credits each payment to the visit and channel that came before it, not to the code. Code redemptions stay in your store or payment provider. Use Virling's campaign report next to your code report to cross-check each partner.
How do I stop discount codes from leaking to coupon sites?
You cannot fully stop it, but you can limit the damage: give each partner a unique code, set an expiry date or a use limit, and retire codes that show up on coupon sites. A tracked link per partner shows the sales they really sent, whatever happens to the code.
See which partners bring paying customers
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.