Overview
The star rating widget provides two rating styles for collecting user satisfaction data: classic star ratings (configurable from 1 to 10 stars) and emoji smiley faces (3 or 5 options). It supports half-star precision, keyboard navigation, and full internationalization.Both star and smiley modes submit to the same unified rating API, making it easy to compare data across styles.
Quick Start
Add star ratings to your page with a single script tag:Configuration Options
Customize the widget’s appearance and behavior using data attributes:Required Attributes
Your unique project identifier from the SeggWat dashboard
Optional Attributes
Rating display style
stars— Classic star rating (default)smiley— Emoji smiley face rating
Number of stars to display (stars mode only). Accepts values from 1 to 10.Example:
Number of smiley faces (smiley mode only). Only
3 or 5 are supported.3— Bad, Okay, Great5— Terrible, Bad, Okay, Good, Great
Custom label text above the rating controls. You can also use
data-question as an alias.Defaults to “Rate your experience” for stars and “How was your experience?” for smiley mode. Translated automatically based on language.Enable half-star ratings for more precise feedback (stars mode only)Example:
Display the numeric rating counter (e.g., “3/5”) next to the starsSet to
false to hide the counter.Remove the top border styling for a more compact lookUseful when embedding the widget inside existing UI components.
Hex color code for filled stars and active smiley highlightsExample:
CSS selector for custom placementBy default, the widget inserts inline at the script tag location. Use this to place it in a specific container.Example:
Language code for the widget UISupported languages:
en, de, svFalls back to English if unsupported. Auto-detects from browser if not specified.Track ratings against specific application versions (e.g.,
1.2.3, v2.0.0-beta)Helps correlate ratings with releases and identify version-specific satisfaction trends.Show or hide the “Powered by SeggWat” brandingSet to
false, 0, or no to hide the branding.Override the API endpoint (useful for self-hosted or staging environments)
Examples
Basic Star Rating
10-Star Scale
Half-Star Precision
Smiley Faces (3 Options)
Smiley Faces (5 Options)
Custom Label
German Language
Full Configuration
JavaScript API
The widget exposes a global API for programmatic control:Set User ID
Associate ratings with specific users:- Max 255 characters
- Alphanumeric characters, hyphens, and underscores only
- Examples:
user_12345,cust-abc-123,USR_98765
Reset Widget
Reset the widget to its initial state:Get Current Rating
Retrieve the current rating value:Get Current Style
Check which rating style is active:Access Container
Access the widget’s DOM element:Keyboard Navigation
The widget supports full keyboard navigation:| Key | Action |
|---|---|
Arrow Left / Arrow Down | Decrease rating by one |
Arrow Right / Arrow Up | Increase rating by one |
Enter / Space | Submit the current rating |
Use Cases
Product Pages
Let customers rate products with familiar star ratings. Compare satisfaction across your catalog.
SaaS Applications
Measure feature satisfaction with quick smiley ratings. Track happiness over time and across releases.
Support Articles
Go beyond helpful/not helpful with granular star ratings on support content.
E-commerce
Collect post-purchase ratings inline on order confirmation or product detail pages.
How It Works
- The script loads and auto-detects your site’s base URL
- Core library loads automatically if not already present
- Widget inserts at script location (or specified container)
- User interacts with stars or smiley faces
- Rating submits to
POST /api/v1/ratings - Widget shows thank you message
- Widget enters submitted state (no duplicate submissions)
API Endpoint
The widget submits ratings to:rating.value— The selected rating (1 tomax_stars, supports 0.5 increments with half-stars)rating.max_stars— The configured maximum (1-10)context.version— Only included ifdata-versionis setcontext.submitted_by— Only included ifsetUser()was called
201 Created on success
Best Practices
Choose the Right Style
Choose the Right Style
Use stars for detailed feedback (product ratings, feature satisfaction). Use smiley faces for quick pulse checks (post-interaction, support articles).
Match the Scale to Context
Match the Scale to Context
A 5-star scale works for most use cases. Use 10 stars when you need finer granularity (e.g., NPS-style surveys). Use 3 smiley faces for the quickest feedback.
Match Your Audience
Match Your Audience
Set
data-language to match your primary audience’s language. The auto-detection works well for multilingual sites.Track by Version
Track by Version
Use
data-version to correlate ratings with specific releases. Identify whether updates improve or hurt satisfaction.Track Authenticated Users
Track Authenticated Users
For logged-in experiences, use
setUser() to prevent duplicate ratings and enable per-user analytics.Styling
The widget uses the SeggWat design system and adapts to light/dark mode automatically. CSS Classes (for custom styling):.seggwat-star-widget— Root container.seggwat-star-bordered— Applied when not inline.seggwat-star-inner— Inner wrapper.seggwat-star-label— Label text.seggwat-star-container— Stars/smiley container.seggwat-star-rating— Star rating group.seggwat-star— Individual star.seggwat-star.filled— Filled star.seggwat-star.half-filled— Half-filled star.seggwat-star-count— Rating counter.seggwat-star-hover-text— Hover description text.seggwat-smiley-faces— Smiley container.seggwat-smiley-face— Individual smiley button.seggwat-smiley-face.selected— Selected smiley.seggwat-smiley-face.dimmed— Dimmed after submission.seggwat-smiley-emoji— Emoji element.seggwat-smiley-label— Label below emoji
Accessibility
The star rating widget is built with accessibility in mind:- ARIA
radiogrouprole with individualradioroles for each option - Keyboard navigation with arrow keys and Enter/Space
- Focus indicators for keyboard users
- Hover text descriptions for each star level
- Disabled state after submission
- Sufficient color contrast
Troubleshooting
Widget not appearing
Widget not appearing
Check these issues:
- Verify the script URL is correct:
https://seggwat.com/static/widgets/v1/seggwat-star.js - Ensure your project key is correct
- Check browser console for JavaScript errors
- If using
data-container, verify the selector exists in the DOM
Ratings not submitting
Ratings not submitting
Common causes:
- Check browser Network tab for failed API calls
- Verify you’re viewing the correct project in dashboard
- Rate limiting (10 second cooldown between submissions)
- Check for CORS issues in console
Half-stars not working
Half-stars not working
Solutions:
- Ensure
data-allow-half="true"is set - Half-stars only work in stars mode, not smiley mode
- Click on the left half of a star for a half rating
Translations not loading
Translations not loading
Check:
- Language code is valid:
en,de, orsv - Network tab shows translation file loading
- Falls back to English if translation file fails
- Custom
data-api-urlpoints to correct server
Smiley mode showing wrong number of faces
Smiley mode showing wrong number of faces
Solutions:
- Ensure
data-style="smiley"is set data-facesonly accepts3or5(defaults to 3 for other values)data-max-starshas no effect in smiley mode