Skip to main content
Once the script is on the page it exposes a global window.clickbase you can call from your own code — to send custom events, report revenue, identify visitors, drive pageviews manually, report errors, and control session replay.

The queue: safe to call before load

The snippet installs a tiny stub synchronously, then loads the real widget asynchronously. The stub queues any call you make and the widget drains the queue once it finishes loading, so you never have to wait — call clickbase.* as soon as the snippet tag is in the page. Two methods are synchronous getters that must return a value immediately, so before the widget has loaded they return a safe default:
  • getVisitorId() returns null until loaded.
  • getSessionId() returns null until loaded.
  • isSessionReplayActive() returns false until loaded.
Every other method is queued and runs in order once the widget is ready.

Methods

event(name, options?)

Record a custom event.
Reserved names are refused (see Reserved names).

sale(name, revenue, options?)

Report a one-off, client-reported sale. Revenue is a required positional argument.

subscription(name, revenue, options?)

Report a recurring-flavored client-reported revenue event. Same mechanics as sale(); the name is for readability — it cannot represent a real subscription lifecycle (only Stripe can). Revenue is required.
Reported revenue from sale() / subscription() / event({ revenue }) attaches to goals for attribution — it is never treated as verified money and never reaches the Revenue page or MRR. See Track revenue and Revenue.

identify(payload, callback?)

Associate the current visitor with a known identity (a “site user”). See People.

pageview(options?)

Record a pageview manually. Useful with data-manual="true", which turns off all automatic pageviews (see Pageviews & SPAs).
options is an EventOptions; the url field overrides the recorded path.

error(error, context?)

Report an error manually. No-op unless error tracking is enabled for the site (track_errors).
Unhandled errors and promise rejections are captured automatically when track_errors is on — see Error tracking.

startSessionReplay() / stopSessionReplay()

Manually start or stop recording the current session for replay.
startSessionReplay() is a no-op unless session replay is enabled for the site (track_session_replay) and the current session is within the configured sample rate.

isSessionReplayActive()

Returns boolean — whether replay is currently recording. Synchronous; returns false before the widget has loaded.

getVisitorId()

Returns string | null — the current visitor id, or null before the widget has loaded and in cookieless mode where no id is stored. Synchronous.
The main use is bridging a server-side Stripe checkout back to the visit that earned it — see Track revenue → Attribute a Stripe checkout.

getSessionId()

Returns string | null — the current analytics session id (_cb_sid), or null before the widget has loaded and in cookieless mode. Synchronous. Sliding inactivity window matches the product-wide session duration (config('clickbase.session_duration_minutes'), default 30 minutes).
Optional companion to getVisitorId() on Stripe Checkout / PaymentIntent metadata as clickbase_session_id. Visitor remains the primary attribution join key.

Types

PropertyMap

RevenuePayload

Integer minor units (cents), not dollars — $49.90 is 4990.

EventOptions

RevenueEventOptions

Options for sale() / subscription() — revenue is a required positional argument on those methods, so it is not part of these options.

IdentifyPayload

DeliveryCallback

Called with the outcome of the network delivery.

Reserved names

event(), sale(), and subscription() all refuse the event names Clickbase writes only from trusted server sources, so a browser can never forge verified revenue. A refused call sends no beacon, logs a console.warn, and fires the delivery callback with status: 'ignored'. The reserved names (case-insensitive) are: payment, free_trial, trial_started, trial_converted, subscription_started, subscription_renewed, subscription_upgraded, subscription_downgraded, subscription_cancel_scheduled, subscription_reactivated, subscription_ended. See Track revenue for why these are locked, and Goals for the matching server-side rule.