Before you start
- Create a workspace and project in the dashboard, then copy the project’s publishable key (
pk_...) from Settings → API Keys. - Add your production origin under Settings → Allowed origins. For local testing, enable Dev mode for 24 hours. A new project rejects every origin with
403until you allow one, including localhost. - Choose how your app supplies the visitor’s analytics consent. Pageviews are optional and need a plan with a pageview allowance; the free plan has none.
Install the SDK
Install@wendung/sdk from npm using your preferred package manager.
Initialize the SDK
ImportWendung and call init() once when your application boots in the browser. Only apiKey is required. Keep the optional settings in this same call:
setConsent() to apply granted or denied, and pass its saved choice to init() on later loads. The SDK does not store the choice. If you omit consent, it defaults to granted and full analytics uses browser identifiers.
The identify() and step() examples below require granted consent. Calls made while pending are dropped, with no replay; identify an already signed-in user again after consent is granted. See the consent guide for the complete wiring.
Set debug: true in the same configuration during development to log SDK activity. Warnings are logged regardless of this setting.
Identify the user
Once the user is known, usually after login, callidentify() to attach all subsequent events to them. The traits you pass are included with every event that follows.
init(), so a reload keeps the user identified. Each identify() call replaces it wholesale, traits included, so pass the full trait set every time. Call reset() on logout to clear it.
Track your first funnel step
Callstep() with a step name (1–100 characters, matching a step in one of your funnels) and an optional properties object. The event is queued immediately and sent with the next flush.
Optional: turn on pageview tracking
Funnels come from the steps you name. Web analytics comes from pageviews. Choose atrackPageviews value in your existing initialization above:
truerecords full pageviews only after consent is granted.'auto'records aggregate pageviews while consent is pending, then full pageviews after consent is granted. Aggregate pageviews contain no visitor or session identifiers.
Flushing happens automatically
You don’t need to manage flushing yourself. The SDK sends queued events:- Every 5 seconds, on a timer
- As soon as the queue hits the batch size (default 50 events)
- On page hide, draining the whole queue with
fetchandkeepalive: trueto attempt delivery during unload
await Wendung.flush(). It sends at most one batch per call and never rejects.
Optional: let an agent add the SDK
Drop this prompt into your AI coding agent and let it guide you through the setup:Prompt
What’s next
Now that events are flowing, head back to the dashboard. Create a funnel from the step names you track, and open your site under Sites for traffic.Create your first funnel
Turn the step names you’re tracking into a funnel in the dashboard.
Set up web analytics
Register your site, clean up paths, and read the site dashboard.
Next.js integration
The recommended setup pattern for App Router and Pages Router.