Web
Track key events in websites and web apps with the Formo Web SDK. Learn more about how to set up and configure the Formo Web SDK to measure what matters onchain.
The Formo Web SDK is open source and implements the standard Events API.
Installation
Websites
Install this snippet at the <head>
of your website:
React and Next.js
Install the JavaScript SDK via CDN or NPM.
Autocapture
The Web SDK automatically captures common events such as page views and wallet events (connect, disconnect, signature, transaction, etc) with full attribution (referrer, UTM, referrals.)
You do not need to configure anything to track these events.
Identify users
Call identify()
after a user connects their wallet or signs in on your website or app:
If no parameters are specified, the Formo SDK will attempt to auto-identify the wallet address.
Track events
Track user actions by calling the SDK track()
function:
Code examples
Check out working examples of Formo on Github:
Example Next.js app
A working example of Formo in a Next.js app.
Example React app
A working example of Formo in a React app.
Configuration
Autocapture
You can configure which events are automatically captured by the SDK:
Local testing
The SDK skips tracking in localhost by default. To enable tracking locally during development, set trackLocalhost
to true
:
Logging
Control the level of logs the SDK prints to the console with the following logLevel settings:
Batching
To support high-performance environments, the SDK sends events in batches.
Customize this behavior with the flushAt
and flushInterval
configuration parameters.
Log Level | Description |
---|---|
trace | Shows the most detailed diagnostic information, useful for tracing program execution flow. |
debug | Shows all messages, including function context information for each public method the SDK invokes. |
info | Shows informative messages about normal application operation. |
warn | Default. Shows error and warning messages. |
error | Shows error messages only. |