Skip to main content
The Usertick JavaScript SDK is the runtime that shows website surveys. The script tag and the @usertick/snippet npm package load the same runtime and expose the same methods.

SDK reference

Every method: init, on, off, show, hide, trigger, identify, logout, reset and destroy.

SDK events

The open, close, submit and error events and the data each one carries.

Install on your website

The script tag, platform guides and the install check.

Install with npm

The npm package, with React, Next.js, Vue and Angular examples.

Load the SDK

Both use the site ID from Settings → Sites. The script tag starts the widget by itself, and the npm package starts it when init is called. With the script tag, the API is on window.Usertick; with the package, it is the default export.

How the runtime behaves

  • Asynchronous. The script tag loads with async, so the page never waits for it. When Usertick can’t be reached, the page works as usual without the widget.
  • Isolated. The widget renders inside a closed Shadow DOM, so the page’s CSS and the widget’s CSS don’t affect each other.
  • Queued calls. The script tag defines Usertick before the full runtime loads. Calls to init, on, off, show, hide, identify, logout, reset and destroy made in that time are queued and run in order once it loads. Events sent with trigger are kept for 10 seconds after the widget is ready.
  • Offline queue. When a response can’t be sent because of a network error, the runtime keeps it in the browser and retries in the background and on later page loads, for up to 7 days. For a survey with a closing date, a response given before the close is accepted only when it arrives within 3 days of it.
  • One runtime per page. When the script tag and the npm package are both on a page, the second copy finds the first and stays idle.
  • Domain check. The runtime shows surveys only on the domain of the site whose ID it carries, and on its subdomains.
  • Route changes. The runtime follows client-side navigation in single page apps, so page rules are checked again after each route change.