Skip to main content
The Cano JavaScript SDK lets you track events and identify users from both browser and Node.js environments using a lightweight, promise-based API. Whether you’re building a React SPA, a Next.js app, or a server-side Node service, the SDK handles batching, retries, and session management so you can focus on instrumentation.

Installation

Install the SDK using your preferred package manager.

CDN (no bundler)

If you’re not using a bundler, load the SDK directly from the Cano CDN by adding this tag to your HTML <head>:
index.html
After the script loads, the Cano constructor is available on window.Cano.

Initialization

Import and instantiate the client once — typically in your app’s entry point — then reuse it throughout your codebase.
app.js
Pass { autoTrack: true } in the constructor options to automatically capture page views and click events without any additional code. This is ideal for quick prototypes or content sites where manual instrumentation isn’t practical.

Core Methods

cano.track(event, properties?)

Call track every time a user performs a meaningful action. Pass an event name and an optional object of properties that describe the action.

cano.identify(userId, traits?)

Call identify when you know who the current user is — for example, after they log in or sign up. Pass a stable user ID and any traits you want to associate with that profile.

cano.page(pageName?, properties?)

Call page to record that a user has viewed a page or screen. Supply an optional name and any additional context about the page.

cano.setSuperProperties(properties)

Super properties are key-value pairs that are automatically merged into every subsequent track call. Use them for attributes that apply across all events — like app version or environment.

cano.alias(newId, previousId)

Call alias to merge two user identities — for example, when an anonymous visitor signs up and you want to connect their pre-signup activity to their new account.

cano.reset()

Call reset to clear the current user’s identity and super properties from the SDK — typically on logout. Subsequent events will be attributed to a new anonymous session.

cano.flush()

flush forces the SDK to immediately send any events queued in memory, bypassing the normal batchSize and flushInterval thresholds. It returns a Promise that resolves when the flush completes.

Error Handling

Wrap flush() calls in a try/catch (or .catch) to handle network errors and API rejections gracefully.
error-handling.js
Individual track, identify, and page calls are buffered in memory and do not throw on their own. Errors surface when the buffer is flushed — either automatically by the SDK or manually via cano.flush().

TypeScript Support

The SDK ships with first-class TypeScript definitions — no @types package needed. All constructor options, method signatures, and event property maps are fully typed.
app.ts