FeedbackJar

Initialization

Initialize the FeedbackJar widget on your website.

Basic Initialization

javascript
window.fj.init('YOUR_WIDGET_ID');

With Configuration

javascript
window.fj.init('YOUR_WIDGET_ID', {
  position: 'right',
  theme: 'auto',
  trigger: 'default'
});

Parameters

widgetId (required)

  • Type: string
  • Description: Your unique widget ID from FeedbackJar dashboard

options (optional)

Configuration object with the following properties:

position

  • Type: 'left' | 'right'
  • Default: 'right'
  • Description: Position of the feedback button on screen

theme

  • Type: 'auto' | 'light' | 'dark'
  • Default: 'auto'
  • Description: Color theme for the widget
    • auto - Follows system preference
    • light - Light mode
    • dark - Dark mode

trigger

  • Type: 'default' | 'custom'
  • Default: 'default'
  • Description: Control visibility of default feedback button
    • default - Shows floating feedback button
    • custom - Hides button, use your own trigger with showWidget(). showWidget() works with custom even when the dashboard “widget” switch is off

widget

  • Type: boolean
  • Default: Dashboard “widget” switch
  • Description: Turn the widget on or off from code. Overrides the dashboard switch. With trigger: 'default', showWidget() does nothing while this is false. Set widget: true to force it on

Configuration Fetched from API

When you initialize, the widget automatically fetches additional configuration from the FeedbackJar API, including:

  • Custom colors and styling
  • Widget title and subtitle
  • Button customization
  • Input field styling

This allows you to customize the widget appearance from your dashboard without code changes.

Example: Full Configuration

javascript
window.fj.init('wgt_abc123xyz', {
  position: 'left',
  theme: 'dark',
  trigger: 'custom'
});

Return value

init() returns a Promise<void>. It resolves after the widget config loads. Await it if you need the widget ready before the next step.

javascript
await window.fj.init('YOUR_WIDGET_ID');

Queued calls run in order, and each one waits for the call before it. init(id); showWidget() is safe before the SDK loads.

Async Loading

The SDK uses async loading to minimize impact on page load. Methods called before the widget fully loads are queued and executed once ready.

javascript
// These calls are queued if SDK isn't loaded yet
window.fj.init('YOUR_WIDGET_ID');
window.fj.identify({ id: '123', email: 'user@example.com' }); // display-only unless signed
// Widget will execute both once loaded

Error Handling

If initialization fails (invalid widget ID, network error), the widget fails silently without breaking your page.

Check browser console for error messages during development.