Skip to content
Open fromusers

In-product JavaScript API

In-product surveys

The FromUsers in-product JavaScript API lets your application initialize context, show surveys on demand, emit trigger events, and submit responses when you need programmatic control.

  • fromusers-sdk.js installed with data-api-key and data-website-id. See Install the SDK.
  • At least one in-product survey on that website for end-to-end tests.
  • Basic familiarity with your front-end codebase.
MethodPurpose
FromUsers.initInitialize or update SDK configuration and user context
FromUsers.showSurveyDisplay a specific survey from code
FromUsers.trackEventEmit a named event for custom triggers
FromUsers.submitResponseSubmit a response programmatically when your flow requires it

Exact argument shapes appear in the snippet and API hints inside FromUsers. Use the method names above consistently in your codebase.

Call init when you know who the user is or when attributes change after login.

Typical uses:

  • Pass user attributes for audience rules.
  • Provide dynamic values for personalization.
  • Re-run setup after client-side authentication.

Example pattern:

FromUsers.init({
user: {
id: "user_123",
plan: "pro",
role: "editor",
},
});

Adapt property names to what your audience rules expect.

Use showSurvey for explicit UI entry points:

  • “Give feedback” buttons
  • Help center widgets
  • Post-task prompts you fully control in code

The survey should still be Live and not blocked by frequency or quarantine. Targeting may still apply depending on how you invoke the method. Always test the path you ship.

Pair with a custom JS event trigger:

  1. In the survey, set the trigger event name (for example export_complete).
  2. In your app, call FromUsers.trackEvent('export_complete') after the action succeeds.
  3. Confirm the survey appears under your frequency rules.
FromUsers.trackEvent("export_complete");

Keep event names stable and documented for researchers configuring triggers.

Use submitResponse when your product UI collects answers outside the default survey chrome and you still want FromUsers to store the response. Most teams rely on the built-in survey UI instead. Prefer the standard display modes unless you have a custom form requirement.

  • Ensure the SDK is loaded before calling methods.
  • After route changes, fire events or re-check eligibility for page-targeted surveys.
  • Guard calls with feature detection if the script might be blocked.
if (window.FromUsers) {
FromUsers.trackEvent("onboarding_finished");
}

Common questions

When should I call showSurvey?

Use it to open a specific survey from your UI after the SDK is installed, for example from a Help menu or after a custom workflow step.

What does trackEvent do?

It records a named event your triggers can listen for, such as export_complete or onboarding_finished.

Is init required if I only use the script tag?

The script tag with data-api-key and data-website-id boots the SDK. Call FromUsers.init when you need to pass user attributes or refresh configuration from code.