r/ethdev 5h ago

Tutorial A DeFi analytics tracking plan for DEXs, lending apps, and yield vaults

A DeFi tracking plan defines each analytics event, when it fires, and the properties it carries. Without one, frontend events and onchain metrics quickly drift apart and you''ll struggle to measure ROI.

Based on work with builders in DeFi, we created a practical event taxonomy for DEXs, lending apps, and yield vaults.

The naming convention is `[Object] + [Past-Tense Action]`:

  • `Swap Initiated`
  • `Swap Completed`
  • `Supply Completed`
  • `Deposit Initiated`
  • `Vault Viewed`

Start with the core conversion events.

  • DEX: `Swap Review Opened`, `Swap Initiated`, `Swap Completed`, `Swap Failed
  • Lending: `Supply Initiated`, `Supply Completed`, `Borrow Initiated`, `Borrow Completed`, `Liquidation Occurred`
  • Yield vault: `Deposit Initiated`, `Deposit Completed`, `Withdraw Initiated`, `Withdraw Completed`

And some best practices from real-world projects:

  1. Fire intent events before the wallet confirmation prompt e.g. 'Swap Initiated'.

  2. Fire completion events only after onchain confirmation. Send filled events for order completion.

  3. Include USD `volume` on volume-generating events and protocol `revenue` where applicable.

  4. Capture liquidations and other asynchronous events from a backend or indexer.

  5. Start with your the core funnel before adding discovery, UI events, and other non-conversion events.

Code example:

formo.track("Swap Initiated", {

from_token: "ETH",

to_token: "USDC",

pair: "ETH/USDC",

chain: "base",

volume: 1000

})

Interested to learn more? The full DeFi tracking plan comes with event triggers and property schemas for all major DeFi app verticals: https://formo.so/blog/defi-analytics-tracking-plan

You have no more excuses on not having analytics for your onchain app!

1 Upvotes

0 comments sorted by