Skip to main content
Use the TinyAnalytics tracking script’s browser API to record visitor activity. Install the tracking script, then call methods on window.tinyanalytics; you do not need an API key or a custom HTTP client.
Never put a TinyAnalytics API key in client-side code. Browser collection is keyless, and the tracking script supplies the site and page context for you.

Available event methods

The tracker automatically records initial pageviews and SPA route changes by default. Call pageview() yourself only when you have disabled automatic pageviews or need to supply a custom path.

Send a custom event

Call event() after the tracking script has loaded:
string
required
A short, stable event name such as signup or checkout_completed. An empty name is rejected in the browser.
object
Optional JSON properties used for breakdowns and filters. The serialized object can be up to 8 KB.
Keep the event name stable and put values that change into properties. For example, use one checkout_completed event with a plan property instead of a separate event name for every plan.

Attach revenue

Put the reserved revenue and currency properties on a custom event:
  • revenue accepts a positive number or numeric string in major currency units.
  • currency is a three-letter currency code such as USD, EUR, or GBP.
See Revenue analytics for reporting behavior, refunds, and currency conversion.

Send a manual pageview

Automatic pageviews and SPA route tracking cover most sites. If you turn automatic pageviews off, send one when your app finishes navigation:
Omit the argument to use the browser’s current location. Outbound links are captured automatically by default. Use trackOutbound() when your app opens an external destination without a normal anchor click:

Track a handled error

Automatic error capture sees uncaught errors when you enable it. Use trackError() inside a catch block or error boundary for an error your app handles:
See JavaScript error tracking for automatic capture and privacy limits.

Call the API after the script loads

The script loads with defer, so event handlers and app lifecycle callbacks can call it normally. Guard code that may run during early page boot:

Verify

1

Trigger the browser call

Open your site in a browser and perform the action that calls event(), pageview(), trackOutbound(), or trackError().
2

Check the matching report

Open Events for custom and outbound events, Pages for pageviews, or Errors for JavaScript errors. The new record should appear within a few seconds.
The client-side integration is working when the browser action appears in its matching TinyAnalytics report.

Custom events

Design stable event names and useful properties.

Browser identity

Identify signed-in users and update traits from client-side code.

Configure the tracking script

Control automatic pageviews and capture options.

Verify installation

Diagnose script loading and event delivery.