Onchain attribution in 2026: the complete guide for DeFi teams

Onchain Attribution: The Complete Guide for DeFi Teams (2026)

Yos Riady

Yos Riady

· Published

· Updated on

Updated

Updated

Key Takeaways

  • Onchain attribution connects GTM and marketing campaigns to wallet activity, protocol revenue, transaction volume, and user retention.

  • A Naughty Marketing report (October 2025) found 70% of DeFi projects fail to demonstrate marketing ROI, a direct consequence of using traditional analytics tools that lose visibility at the onchain layer.

  • Referral codes, UTM, referrer, and builder code tracking are the core methods for linking campaign clicks to wallets, transactions, and volume.

  • Multi-wallet identity resolution improves CAC and LTV accuracy by linking related addresses into user profiles instead of counting each wallet separately.

DeFi’s attribution problem is well-documented, but most guides stop at the theoretical. They explain why connecting a Twitter/X click to a swap matters without explaining how to wire it up or what to do when a user connects three different wallets, jumps across five chains, and never links a single piece of off-chain identity.

This guide closes that gap. The protocols that grow aren’t the ones with the most liquidity incentives. They’re the ones that understand exactly which acquisition channels produce high-value users versus one-time airdrop hunters.

Onchain attribution is how you tell the difference.

Why traditional attribution breaks in DeFi

Google Analytics tracks sessions. Mixpanel tracks events. Neither has any visibility into what happens after a user leaves your site and interacts with your smart contract.

This creates a hard break in the data: you can see that a user arrived from a Twitter/X campaign, browsed your app, and connected their wallet, but the moment they execute a transaction onchain, they disappear from your analytics. You lose sight of whether they swapped $500 or $500,000, whether they returned the next day or churned, and whether they ever generated protocol revenue at all.

The problem is structural. Traditional attribution depends on cookies, device fingerprints, and persistent session identifiers. DeFi users operate through pseudonymous wallet addresses, move across chains, and frequently use different wallets for different protocols. There is no persistent identity layer unless you build one.

A Naughty Marketing report from October 2025 estimated that 70% of DeFi projects fail to demonstrate their marketing ROI, a direct consequence of using traditional tools to measure web3 behaviour.

The three core onchain attribution methods

No single technique solves the full attribution problem. Robust onchain attribution in 2026 combines three complementary approaches.

1. Referral and UTM attribution

Referral codes and UTM parameters remain the backbone of any onchain attribution system. The implementation is deliberate but not complex:

  • Tag every outbound link with UTM parameters: ads, KOL posts, Discord announcements, and email campaigns. Use a consistent naming convention so your reports stay clean.

  • Capture UTMs on landing using a JavaScript snippet that reads URL parameters and connects them to the user’s session or device. This ensures the data persists even if the user browses multiple pages before connecting their wallet.

  • Connect UTMs to the wallet address at the moment of connection. When a user connects MetaMask or Phantom, your frontend reads the stored UTM data and sends both the wallet address and campaign metadata to your analytics layer.

  • Attribute onchain events by joining wallet addresses to UTM records whenever a transaction fires: swaps, deposits, borrows, or any contract interaction you track.

The result: a traceable line from a specific campaign to specific protocol revenue. A user who arrived via a KOL post and subsequently deposited $50,000 into your liquidity pool shows up attributed to that campaign, with their full transaction history attached.

Platforms like Formo handle this end-to-end, capturing the referral and UTM parameters at first visit, connecting it to the wallet on connect, and surfacing results in attribution reports that show volume, revenue, and retention broken down by channel, without requiring a custom data pipeline.

2. Referrer-based attribution

Browser referrer data captures the domain a user arrived from without requiring explicit UTM tagging. This is a lower-fidelity signal, you know someone came from Twitter/X, but not which tweet or campaign, but it fills gaps where UTM tagging isn’t feasible, such as organic mentions or aggregator links.

Referrer attribution works best as a fallback: when UTM data is present, use it. When it’s absent, referrer data still assigns channel-level attribution, which is far better than nothing.

3. Builder code attribution

Referral parameters such as builder codes built into smart contracts offer a fundamentally different model, one that doesn’t depend on off-chain tracking at all. When a referring wallet is passed as a parameter in a contract call, or when a unique referral code is encoded in the transaction itself, attribution becomes fully verifiable onchain.

This approach suits protocols that run structured referral programs: perpetual exchanges, lending protocols, and cross-chain bridges use it frequently. The trade-off is scope: you only capture users who came through the referral mechanism. Organic and paid traffic still require UTM or referrer methods.

Attribution models: which touchpoint gets the credit?

Capturing the data is only half the problem. The harder question is how to distribute credit across multiple touchpoints in a user’s journey from first click to first transaction.

  • First-touch attribution gives 100% credit to the channel that first brought the user to your protocol. It favours awareness channels, Twitter/X, podcasts, and content, and is useful for understanding which sources generate net-new users. Its weakness: it ignores everything that happened between discovery and conversion.

  • Last-touch attribution gives all credit to the final touchpoint before a user completes a transaction. This tends to favour retargeting and direct community channels that push users over the line. Useful for optimising conversion campaigns, but it systematically undervalues channels that built initial awareness.

  • Multi-touch attribution distributes credit across the full journey. Linear models split equally across all touchpoints; time-decay models give more weight to recent touches; position-based models weight the first and last touchpoints more heavily and split the remainder across the middle.

For most DeFi growth teams in 2026, all three models has its place. First-touch fits well for acquisition campaign measurement. Last-touch works for conversion-focused reports. According to a 2025 analysis by Impact, multi-touch models improve CPA efficiency by 14–36% compared to single-touch models. Crypto user journeys are often long: a user might encounter your protocol on Twitter/X, read a blog post three weeks later, see a Discord mention, and finally make transactions after receiving a referral link. Neither first-touch nor last-touch alone tells you anything useful about that journey.

The identity problem: wallets are not users

Attribution breaks down when a user has multiple wallets. A DeFi power user might hold a cold wallet for long-term positions, a hot wallet for active trading, and a separate wallet for airdrop farming. If your analytics treats each address as a distinct user, your CAC looks inflated, retention looks lower than it is, and LTV calculations are wrong.

Three approaches address this:

  • Deterministic linking happens when users voluntarily connect their wallet to an off-chain identity, an email address via a sign-in flow, a social account via OAuth, or a verified identity through tools like World ID or Gitcoin Passport. This is the cleanest signal. Formo’s wallet intelligence layer supports it directly, building unified wallet profiles that aggregate onchain activity across multiple addresses tied to a single identity.

  • Probabilistic linking uses behavioural signals, transaction timing patterns, shared gas wallets, and similar transaction structures to infer that two addresses belong to the same user. Useful where deterministic linking isn’t possible, but accuracy trade-offs mean it should supplement rather than replace deterministic methods.

  • Onchain identity resolution leverages ENS names, Lens handles, and other decentralised identity primitives to cross-reference wallet addresses. As ENS adoption grows, this becomes a more reliable signal, particularly for identifying high-value or institutional wallets.

Combining all three produces wallet profiles that reflect real users rather than raw addresses, which is a prerequisite for accurate LTV/CAC measurement in DeFi.

The metrics that matter

Once attribution is in place, the metrics you track change entirely. Impressions and clicks become irrelevant; what matters is what users do onchain after they arrive.

  • Cost per wallet (CPW): acquisition cost normalised to the first meaningful onchain interaction. More useful than CPC because it filters out users who bounced before engaging.

  • Cost per transaction (CPT): acquisition cost normalised to a completed transaction. This is the DeFi equivalent of cost per conversion, and the most direct ROI signal for paid campaigns.

  • Volume attributed: the total transaction volume generated by users from a given channel or campaign. A KOL campaign that costs $20,000 but drives $2 million in protocol volume has a fundamentally different ROI profile than one that drives 5,000 wallet connects and $50,000 in volume.

  • LTV by acquisition channel: which channels bring users who make transactions repeatedly at high volume, versus users who execute once and disappear. The gap between high-LTV and low-LTV acquisition channels in DeFi can be 10x or greater, making this the single most important metric for budget allocation decisions.

  • Retention cohorts by source: what percentage of users from each acquisition month are still active 30, 60, and 90 days later, broken down by channel. These cohorts reveal whether a campaign drove lasting engagement or a temporary spike.

  • Protocol revenue and churn: revenue attributed to specific channels, and the rate at which users from those channels stop making transactions. Together, these define the long-term value of any acquisition investment.

Attributing revenue, not just wallets

Every metric above assumes you can put a dollar figure against a channel. Most DeFi attribution setups cannot, because they stop at the wallet connect and treat everything after it as someone else's problem. A connect costs you nothing and earns you nothing. Revenue is the only number that justifies the spend that produced it.

This section covers how a dollar of protocol revenue gets traced back to the campaign that produced it, and, just as importantly, where that chain breaks.

Volume and revenue are two different numbers

This is the distinction most attribution tooling blurs, and it is the fastest way to overstate a campaign. Volume is what the user moved. Revenue is what you earned from moving it.

Metric

What it measures

Worked example

Volume

The dollar value of the onchain action itself

A user swaps $40,000 of ETH for USDC

Revenue

The fee your protocol actually captured from that action

At 5 basis points, that swap earns you $20

A campaign that drives $2 million in attributed volume sounds transformative. At five basis points it produced $1,000 in protocol revenue. If the campaign cost $20,000, volume says it was a triumph and revenue says it lost you $19,000. Track both, report both, and never let one stand in for the other.

In Formo, volume and revenue are separate first-class metrics on the project overview, each tracked through your own custom events, so the two never get conflated in a report.

The join that has to work

Attributing revenue means holding a chain of three links together. Break any one and the dollar figure silently detaches from the channel that earned it.

Link

What holds it together

What breaks it

Ad click to session

An ad-platform click ID captured on landing, independent of the referrer header

In-app browsers strip the referrer, so paid social misattributes to direct without a click ID

Session to wallet

The wallet connect event, which ties the anonymous session to an address

The user browses on mobile and connects on desktop, or connects a second wallet later

Wallet to revenue

A revenue-bearing event carrying the USD value your protocol captured

Revenue settles in a contract your SDK never observes, so the money is invisible to the funnel

Diagnose in that order. A channel showing traffic but no revenue is almost always a broken link, not a bad channel.

Revenue has to be instrumented, not inferred

No analytics tool can guess what a transaction earned you. Fee logic lives in your contracts, and only you know which portion is yours. Revenue reaches the funnel because you attach a USD value to an event, through custom events that carry a revenue or volume figure.

The common instrumentation mistake is tagging the action next to the money rather than the money itself. A swap completed event tells you activity happened. A fee event tells you what it was worth. Instrument the second one, and carry the value on it.

What you can break revenue down by

Once revenue is flowing as an event value, the useful question is how finely you can slice it. Formo breaks revenue and volume down by:

  • Acquisition channel: 13 channels, classified at ingestion by a priority ladder over the referrer domain, utm_medium, and eight ad-platform click IDs across seven networks

  • Referrer: the individual source domain behind the channel

  • Referral code: your own structured programmes, where the code is the attribution

  • Ad network: Google, Meta, X, TikTok, LinkedIn, Reddit and Microsoft

  • UTM parameter: campaign, source, medium, term and content

  • Builder code: onchain identity written into the transaction itself

  • Context: device, browser, operating system and country

The click IDs matter more than they look. A paid social click that arrives through an in-app browser usually has no usable referrer, so without the click ID the revenue that click eventually produces lands in the direct bucket and the campaign looks dead.

Builder codes make revenue attribution durable

The builder codes covered earlier solve a problem the off-chain trail cannot. UTMs, referrers and click IDs all live in the browser, and the browser is the fragile part: users clear storage, switch devices, route through an aggregator, or complete the transaction in a wallet app that never saw your landing page.

A builder code is written into the transaction calldata under ERC-8021, so the attribution travels with the transaction rather than with the session. It survives the wallet, the RPC provider and the aggregator, which makes it the only revenue attribution that still works when the off-chain trail is gone. The trade-off is unchanged: it covers transactions your app constructs, so it complements the off-chain methods rather than replacing them.

Working out ROAS onchain

With revenue attributed, return on ad spend stops being a proxy and becomes arithmetic. Two campaigns, same budget:


KOL campaign

Paid search

Spend

$20,000

$20,000

Wallets connected

4,100

900

Wallets transacting

290

410

Attributed volume

$2,100,000

$1,400,000

Attributed revenue

$1,050

$9,800

Cost per wallet

$4.88

$22.22

Cost per transacting wallet

$69

$49

ROAS

0.05x

0.49x

On wallets and volume the KOL campaign wins comfortably. On revenue it is beaten nearly tenfold, because it drove a large number of small swaps while paid search drove fewer, larger, fee-bearing ones. Neither campaign is profitable on first-order revenue, which is normal in DeFi and is exactly why LTV by acquisition channel matters: the paid search cohort only has to transact a few more times to clear the bar, and the KOL cohort has to transact roughly twenty times more.

Rank channels by attributed revenue, sanity-check the ranking against volume, and make the budget decision on LTV rather than on either snapshot.

What onchain revenue attribution cannot tell you

Worth stating plainly, because no vendor volunteers it and every one of these will show up in your numbers:

  • Revenue you do not capture in an event is invisible. If the fee is taken by a contract your SDK does not observe, or settled by a partner, it never enters the funnel and the channel that earned it looks unprofitable.

  • Revenue earned outside your own front end cannot be attributed off-chain. Products routed through partner front ends or aggregator interfaces have nowhere to run a tracking script, so that revenue arrives unattributed no matter which tool you buy.

  • Long payback periods fall outside the window. A user acquired in January who becomes profitable in June falls outside any reasonable lookback window, which systematically understates slow-burn channels such as content and community.

  • Multi-wallet users fragment their own revenue. Revenue splits across addresses unless those wallets are linked back to one person, so per-user revenue reads low and per-wallet revenue reads flat.

None of these are reasons to skip revenue attribution. They are reasons to report it with the caveats attached, and to treat an unattributed bucket as a measurement gap to close rather than a channel that failed.

Building your attribution stack: a practical framework

Step 1: Define your event taxonomy

Start with the five to ten onchain events that matter most to your protocol: wallet connect, first transaction, liquidity provision, borrow initiation, referral link generation. For each, decide what metadata to capture: wallet address, transaction hash, token amounts, chain ID, campaign identifiers. Consistency here is what makes your downstream reports trustworthy.

Step 2: Implement UTM capture

Add a JavaScript snippet to your frontend that reads UTM parameters from the URL and writes them to localStorage on landing. On wallet connect, your app reads from localStorage and sends the wallet address plus UTM data to your analytics backend. Most web3-native SDKs, including Formo’s open-source SDK under the MIT licence, handle this in a few lines of code without custom infrastructure.

Step 3: Build your identity layer

Implement deterministic wallet linking wherever your app supports any form of sign-in. If you use identity providers like Privy, Dynamic, or Thirdweb, link the authenticated identity to the connected wallet at login. This one step improves attribution accuracy more than any other single change.

For fully wallet-native apps with no off-chain sign-in, consider adding an optional identity step, a light-touch email capture, or social connect, with a clear user benefit attached. Incentivised identity linking, where users receive a benefit for connecting their identity, consistently achieves much higher opt-in rates than passive prompts.

Step 4: Track smart-contract events

For each high-value onchain event, set up event indexing that captures the wallet address, block number, and any relevant transaction metadata. This is the layer that closes the loop between your marketing data and your actual protocol activity. Tools like Formo connect this directly to your attribution reports, so you can filter campaign performance by onchain outcomes: volume, revenue, retention, rather than just click-through or wallet connect rates.

Step 5: Choose your attribution model and set lookback windows

Decide on your attribution model (first-touch, last-touch, or multi-touch) and set explicit lookback windows, typically 7, 14, or 30 days, depending on your typical time-to-first-transaction. Document this, so your team interprets reports consistently. Attribution numbers are only comparable over time if the rules don’t change mid-measurement.

Step 6: Build attribution reports that connect to growth decisions

The output of your attribution stack should directly inform budget allocation. A channel that drives high wallet-connect volume but low protocol revenue deserves less investment than one that drives fewer users who make high-value transactions. Set up reports that show CPWC, CPT, attributed volume, LTV, and retention side-by-side by channel, then review them with every budget cycle.

Formo’s Chartbuilder and attribution reporting are built for exactly this workflow, with cross-chain coverage across 30+ chains so multi-chain protocols don’t lose attribution when users bridge or complete transactions on a different network.

Common attribution mistakes DeFi teams make

  • Measuring the wrong conversion event. Wallet connect is not a conversion. It’s a signal of intent. The conversion is the transaction, and more specifically, the transaction that generates protocol revenue. If your attribution reports stop at wallet connect, you’re optimising for the wrong thing.

  • Ignoring multi-wallet users. Treating each wallet address as a unique user inflates your reported user counts and deflates your retention numbers. Every team should have a plan for wallet identity resolution, even if it starts with just deterministic linking through their existing sign-in flow.

  • Using inconsistent attribution naming conventions. utm_source=Twitter and utm_source=twitter are different values in most analytics systems. A UTM naming convention document that every team member uses is worth more than any tool.

  • Not accounting for attribution across chains. A user might click a campaign link, connect their wallet on the Ethereum mainnet, and then bridge to Base to execute the actual transaction. Without cross-chain attribution, that conversion is invisible. This is one of the primary reasons purpose-built onchain attribution tools exist; they’re designed to follow the user across chains rather than stopping at a single network.

  • Confusing activity metrics with retention. A user who makes five transactions in their first week and then disappears is not retained. Measure cohort retention at 30 and 90 days, not just raw transaction counts.

The 2026 shift: from measurement to prediction

Attribution in 2026 is moving beyond measurement into prediction. Teams that have 12–18 months of attributed onchain data are starting to use it to build predictive LTV models, scoring new wallet connects on their likelihood to make high-value transactions based on their wallet history, the channel they arrived from, and their early product behaviour.

This is where wallet intelligence becomes a growth lever rather than a reporting function. When you can identify within the first 48 hours of a user’s arrival that their wallet profile resembles your highest-LTV segment, you can prioritise them for high-touch onboarding, direct incentives, or personalised campaigns before they churn.

Building this capability requires a consistent attribution foundation. Teams that invest in clean UTM tracking, deterministic identity linking, and contract-level event indexing now will have the data quality to support predictive models as they mature. Teams that don’t will continue optimising on incomplete signals.

Attribution is not a one-time implementation; it’s a measurement discipline that compounds over time. The protocols building onchain attribution infrastructure today are the ones that will have the clearest picture of their acquisition economics in 2027 and beyond.

Frequently asked questions

What is onchain attribution in DeFi?

Onchain attribution connects marketing touchpoints, such as UTMs, referrers, or referral links, to wallet activity and smart-contract events. It helps teams understand which campaigns drive transactions, revenue, retention, and high-value users.

Why does traditional attribution break in DeFi?

Traditional analytics tools track sessions, cookies, and web events, but they lose visibility once a user interacts with a smart contract. DeFi users make transactions through pseudonymous wallets, move across chains, and may use multiple wallets, which makes web2 attribution incomplete.

What are the main methods of onchain attribution?

The three core methods are UTM-to-wallet attribution, referrer-based attribution, and onchain referral attribution. Most teams need a combination of these methods to connect offchain acquisition data with onchain outcomes.

Which attribution model should DeFi teams use?

Most DeFi growth teams benefit from multi-touch attribution, especially time-decay or position-based models. These models better reflect longer user journeys where someone may discover a protocol on X, return through content or Discord, and make transactions later through another touchpoint.

What metrics matter most for DeFi attribution?

The most useful metrics include cost per wallet connected, cost per transaction, attributed volume, LTV by acquisition channel, retention cohorts by source, protocol revenue, and churn. These show whether a campaign drives real onchain value rather than just traffic or wallet connects.

What are the biggest attribution mistakes DeFi teams make?

Common mistakes include treating wallet connects as conversions, ignoring multi-wallet users, using inconsistent referral codes / UTM naming, missing cross-chain activity, and confusing short-term transaction spikes with real retention.

How do you attribute onchain revenue to a marketing channel?

Hold three links together: an ad-platform click ID ties the click to the session, the wallet connect event ties the session to an address, and a revenue-bearing custom event ties that address to the dollar value your protocol captured. Break any link and the revenue detaches from the channel that earned it. A channel showing traffic but no revenue is usually a broken link rather than a bad channel.

What is the difference between attributed volume and attributed revenue?

Volume is the dollar value of the onchain action. Revenue is the fee your protocol captured from it. A campaign driving $2 million in attributed volume at five basis points produced $1,000 in revenue, so a $20,000 campaign that looks transformative on volume lost money on revenue. Track both and never let one stand in for the other.

About the Author

About the Author
About the Author
Yos Riady

Founder

Founder

Yos is the founder of Formo, where he helps DeFi teams make analytics and attribution simple. Prior to Formo, Yos was a staff software engineer and tech lead at Chainlink Labs. He helped scale Chainlink into the industry-standard oracle for leading DeFi protocols. A long-time builder in crypto with experience across smart contracts, data engineering, and security.

Yos is the founder of Formo, where he helps DeFi teams make analytics and attribution simple. Prior to Formo, Yos was a staff software engineer and tech lead at Chainlink Labs. He helped scale Chainlink into the industry-standard oracle for leading DeFi protocols. A long-time builder in crypto with experience across smart contracts, data engineering, and security.

Table of Contents

Measure what matters onchain

Formo makes analytics and attribution simple for DeFi apps.

Measure what matters onchain

Formo makes analytics and attribution simple for DeFi apps.

Measure what matters onchain

Formo makes analytics and attribution simple for DeFi apps.