JavaScript API
After load, window.usertraxFeedback exposes:
| Method | Description |
|---|---|
open() | Open the feedback panel |
close() | Close the panel |
reset() | Clear form state |
configure({ hideOnPages }) | Update runtime options (e.g. hide widget on certain routes) |
captureException(error, extra?) | Add a JS error to the next submission |
captureMessage(message, extra?) | Add a custom message to the error buffer |
getErrors() | Return buffered errors |
clearErrors() | Clear the error buffer |
Hide on specific pages (SPAs)
Section titled “Hide on specific pages (SPAs)”Hide the widget on routes where feedback does not make sense (checkout, login, admin, …). Matches against location.pathname. Patterns can be exact paths, * globs, regular expressions, or a function. SPA navigations (pushState / replaceState / back/forward) are detected automatically.
<script> window.usertraxFeedback = { hideOnPages: ["/checkout", "/login", "/admin/*", /^\/settings/], };</script><script src="https://usertrax.io/feedback.js" data-key="YOUR_AUTH_KEY" defer></script>Or update at runtime (e.g. from your router):
window.usertraxFeedback.configure({ hideOnPages: ["/checkout", "/cart/*", (pathname) => pathname.startsWith("/app/onboarding")],});open() still works programmatically on hidden pages (e.g. a custom “Give feedback” link). After close(), the widget hides again if the current route matches.
Identify logged-in users
Section titled “Identify logged-in users”Use the tracker API — one call covers conversions and the feedback widget:
usertrax.identify("user-123", { email: "user@example.com", plan: "pro",});If identify ran on a previous page, the widget hydrates automatically from localStorage (usertrax_identify).
Calls before the script loads
Section titled “Calls before the script loads”Queue API calls until the widget is ready:
<script> window.usertraxFeedback = window.usertraxFeedback || {}; (window.usertraxFeedback._q = window.usertraxFeedback._q || []).push([ "configure", [{ hideOnPages: ["/checkout"] }], ]);</script><script src="https://usertrax.io/feedback.js" data-key="YOUR_AUTH_KEY" defer></script>Identify before either script loads via the tracker (persisted for the widget):
<script> // After tracker.js is available, or queue until it is: usertrax.identify("user-123", { email: "user@example.com" });</script>Programmatic open
Section titled “Programmatic open”Useful for a custom “Give feedback” link in your app:
document.querySelector("#feedback-link").addEventListener("click", (e) => { e.preventDefault(); window.usertraxFeedback.open();});