Product Analytics
Capture how people use your product in the browser — page views, UI interactions, and custom business events — without shipping a separate analytics vendor.
Events land in your Ductape workspace and are visible in Workbench → Logs (filter by Frontend). You can track anonymous visitors before login and authenticated users after your backend issues a session JWT.
- @ductape/client
- React
- Vue 3
Overview
ductape.analytics is the browser-side product analytics API. It batches events and sends them to Ductape over the analytics ingest endpoint (/v1/analytics/track). Use it to answer questions like:
- Which pages do visitors land on before signing up?
- Where do users drop off in onboarding?
- Which features are used after launch?
- What path did a specific user take before converting?
Anonymous and authenticated tracking
You can track users before they log in.
On first visit the client creates a stable visitor_id (UUID stored in localStorage). Every event includes this id until the user clears site data.
After your backend returns a session JWT, call identify(sessionToken) so subsequent events also carry session_id and session_user_id. Events recorded after identify include both the visitor id and session fields — useful for stitching pre-login browsing to post-login activity.
On logout, call clearSession() so new events are anonymous again (the same visitor_id is retained).
// Logout handler
ductape.analytics.clearSession();
Quick start
import { Ductape } from '@ductape/client';
const ductape = new Ductape({
publishableKey: 'pk_…',
product: 'my-product',
env: 'prd',
});
// Anonymous — no session required
await ductape.analytics.track({
event: 'pricing_viewed',
properties: { plan: 'pro' },
});
// After your backend returns a session JWT
ductape.analytics.identify(sessionTokenFromBackend);
await ductape.analytics.track({
event: 'checkout_started',
properties: { cartTotal: 99, itemCount: 3 },
});
// Standard pageview (manual)
await ductape.analytics.pageview({ title: 'Checkout' });