Skip to content

Configuration

InsightJS.init(options) is optional. It is idempotent and safe to call once, directly after the tag.

option type default meaning
endpoint string the script's own origin Base URL for beacons; the client posts to <endpoint>/speed.
disabled boolean false Sends nothing. It also cancels the deferred first page view, so call it before that view leaves.
debug boolean false Logs the endpoint, init and tracked events to the browser console.

endpoint must be an absolute http or https URL; a trailing slash is ignored. It is not validated beyond that.

Public API

call result
InsightJS.init(options) Applies the options and returns the client.
InsightJS.track(name, props) Sends one event inside the normal envelope. name is truncated to 64 characters; props must be JSON-serializable.
InsightJS.flush() Sends the session summary immediately.

The client is created on the page as window.InsightJS and is guarded against double loading: a second copy of the tag is a no-op.

Options before load

init() is enough when it runs directly after the tag. To set an option before the client loads at all, put it on the window first:

<script>
  window.insightjsConfig = {
    endpoint: 'https://analytics.insightjs.com',
    disabled: true,
    debug: true,
  }
</script>
<script src="https://insightjs.com/l.js"></script>

insightjsConfig is read once, at startup; later changes need init().

Notes

  • There is no sampling option: every page view and route change is sent.
  • track() does not count as a page view; flush() does not either.
  • The client keeps working when PerformanceObserver, history or sendBeacon is missing. Missing features degrade to zero values, not errors.