Initialization
Initialize the FeedbackJar widget on your website.
Basic Initialization
window.fj.init('YOUR_WIDGET_ID');
With Configuration
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 preferencelight- Light modedark- Dark mode
trigger
- Type:
'default' | 'custom' - Default:
'default' - Description: Control visibility of default feedback button
default- Shows floating feedback buttoncustom- Hides button, use your own trigger withshowWidget()
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
window.fj.init('wgt_abc123xyz', {
position: 'left',
theme: 'dark',
trigger: 'custom'
});
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.
// 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' });
// 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.