Skip to content

JavaScript API

After load, window.usertraxFeedback exposes:

MethodDescription
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 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.

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).

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>

Useful for a custom “Give feedback” link in your app:

document.querySelector("#feedback-link").addEventListener("click", (e) => {
e.preventDefault();
window.usertraxFeedback.open();
});