- How to add ratings and reviews widgets using Voyado’s JavaScript SDK
- Single Page Application handling
- CSS custom properties for further customization
Environments
Voyado provides you with two isolated environments. Each has its own script URL, backend, and data store meaning that nothing is shared between them.Setting up
The basic steps to get ratings and reviews on your site are:- Include the script — Load the
voyado.jsscript via GTM or a<script>tag - Add HTML containers — Place
<div>elements with the right CSS class anddata-product-idwhere you want widgets - Call
load-widgets— Tell the SDK which widget types to render
1 - The scripts
Start by creating two Custom HTML tags in GTM that both fire on All Pages.- The first tag loads the script and configures the session
- The second identifies the logged-in user
Show configuration script for Staging
Show configuration script for Staging
Show login script for Staging
Show login script for Staging
Show configuration script for Production
Show configuration script for Production
Show login script for Production
Show login script for Production
{{DL - ...}} with your own GTM Data Layer variables.Adding queuing function (required)
The GTM tag above loadsvoyado.js asynchronously. This means your page code may call voyado('load-widgets', ...) before the script has finished loading, resulting in a ReferenceError: voyado is not defined.
To prevent this, add the following minimal stub to your <head> before the GTM snippet. This creates a queuing function that captures any calls made before voyado.js arrives, which the SDK replays automatically on bootstrap.
See queuing function stub
See queuing function stub
voyado() calls made anywhere on that page are then safe regardless of the GTM load timing.
Load widgets
Create additional Custom HTML tags for each page type. Fire them on the appropriate triggers (for example a DOM Ready trigger filtered by the page path).Category / listing pages
Category / listing pages
Product detail pages
Product detail pages
SPA route changes (if applicable)
If your site is a SPA (Single Page Application) then create a tag that fires on your virtual page-view trigger:Single Page Application
2 - Widget Containers (HTML)
Place<div> containers anywhere in your HTML. These containers must be pure HTML, they cannot be injected by GTM. They must be part of your page templates.
Example values are:
data-product-group-id= “SKU”data-product-id= “SKU-Green”data-variant-id= “SKU-Green-Small”
- PLP = Product Listing Page
- PDP = Product Detail Page
Stars widget (PLP - product cards)
This is a compact star rating for product listing pages. Supports multiple instances per page via the class selector.Stars widget
- Add
voyado-stars--smallfor 16 px stars (default is 40 px)
Ratings widget (PDP — inline)
This is an inline star \ score count. It is typically placed near the product title.Ratings widget
voyado-ratings--small(16 px text)voyado-ratings--vertical(stacked layout)- Or both combined.
Badge widget (PDP — sidebar)
This includes a large numeric score, stars, a review count and a “Review this product” CTA that opens the review popup.Badge widget
voyado-badge--compactfor a smaller score (48 px instead of 78 px with CTA hidden)
Summary widget (PDP)
This includes AI generated sentiment highlights from customer reviews. It is automatically hidden when there are no reviews.Summary widget
Reviews widget (PDP)
This is a full review list with sort dropdown, pagination, author, date, star rating, text, verified-buyer badge, thumbs up/down voting, and comment threads. Authenticated users can edit their own reviews.Reviews widget
voyado-reviews--boxedwraps each review in a card
Highlights widget (PLP / PDP)
This is a single AI-selected review excerpt including title, date, and a “Powered by Voyado” footer. It is lighter than the full Summary widget.Highlights widget
Distribution (PDP — rating breakdown)
Five-row breakdown (5★ down to 1★), each row showing a mini star icon, the review count for that star value in parentheses, and a horizontal bar sized to that rating’s share of all reviews. This is the widget referenced internally as “rating breakdown (5★/4★/3★…).”Distribution widget
Carousel (PDP — scrolling review cards)
A horizontally-scrolling row of review cards under the heading “What our customers are saying,” with prev/next nav buttons. Supports two optional filtering attributes not used by any other widget:data-min-rating: Include only reviews at or above this star rating (for example, 4 means show only 4 and 5 star reviews)data-max-review-count: Cap the number of review cards rendered (for exampple, 10)
Carousel widget
Add Review (PDP — standalone collection button)
A standalone CTA button that opens the review-submission modal directly.Add Review widget
3 - Loading widgets
This is how the widgets are loaded:Loading widgets
- “stars”
- “ratings”
- “badge”
- “summary”
- “reviews”
- “highlights”
- “distribution”
- “carousel”
- “add-review”
PLP example
PDP example
Clearing widgets
To clear the loaded widgets, call:load-widgets again after the new view is rendered.
Starting from zero
When starting off, when a product has no reviews and the goal is not to display but to start collecting, Voyado recommends using only theadd-review widget and “Add Review” button.
When there are no reviews, other display widget either will show an empty/zero state or hides themselves, which reads as broken or unfinished to a shopper. The “Add Review” button however works identically no matter how many reviews a product has.
Once a product has a meaningful number of reviews, add the other display widgets. The “Add Review” button can still remain.
SPA Handling
If your site uses client-side routing (single page application), callreset-widgets before each navigation and then load-widgets after the new content is in the DOM:
SPA Handling
CSS Customization
All visual tokens are CSS custom properties on:root. Override them to match your brand.

