How To

Ratings / Reviews

12min
this guide will cover the options for rating/review indexing as well as where to locate the elements necessary for display customization within template js ratings and review data can can be used by klevu to display rating “stars” and review “count” in the result set display allow the visitor to refine/filter results by the number of rating “stars” allow the visitor to sortby rating “stars” enable klevu machine learning to consider the ratings in relevancy ranking see this knowledge base guide on how to enable each of the above in order to allow klevu the rating and review count data must first be indexed to klevu in one of the following ways within the feed xml file within the klevu indexing api using one of the supported 3rd party connectors custom field mapping using one of klevu's supported platform apps/plugins please contact klevu support for further details on this option indexing the rating and review count data must be supplied at the product level during catalog indexing xml feed example \<item> \<rating>4 5\</rating> \<rating count>10\</rating count> \</item> see xml feed example for ratings api reference indexing attribute description format rating the rating of your product, between 0 and 5 decimal rating count the number of ratings given by customers for your product integer see klevu api documentation for data indexing docid 5yqa6etayyyqzwqhfx db customizing css the “star” images used in the default template js layout are 2 different images they are overlapped and displayed at a width percentage that is appropriate for the rating value of the record gray star https //js klevu com/klevu js v1/img 1 1/star gray png yellow star https //js klevu com/klevu js v1/img 1 1/star yellow\ png the following class selectors can be overridden to consider different images or other desired effects kufiltertagscontainer klevufacetstars { height 15px; display inline block; vertical align bottom; background transparent url(https //js klevu com/klevu js v1/img 1 1/star gray png) top left repeat x; width 65px; } kufiltertagscontainer klevufacetstars klevufacetrating { background transparent url(https //js klevu com/klevu js v1/img 1 1/star yellow\ png) top left repeat x; height 15px; } see styling css docid 2evmr7ofkw87yl6atyu 6 for further details on overriding template js default css sorting the template js sortby feature can be modified to include rating ascending/descending order sort parameter value description rating asc, rating desc sort the results by each record's average rating, if this data has been indexed in your store see sortby options docid\ zvxp bnev c7j ibvzhkx guide for examples of modifying template js default sorting options filtering filtering by rating “stars” is accommodated like all template js facets the key value pairs are as follows description key value one star rating 0 1 5 two stars rating 1 51 2 5 three stars rating 2 51 3 5 four stars rating 3 51 4 5 five stars rating 4 51 5 5 see klevu api documentation for applying facets template js override be advised the calculations within the default template js are carefully constructed to accommodate the existing css and “star” graphics please take caution when modifying these aspects of the template(s) there are three default templates that can be accessed should you choose to override for ratings customizations klevulandingproductrating used for product block display klevulandingtemplatefilters used for filter section kufiltertagstemplate used for active filter tags see set template docid 6yvx9naw6ax68wygucob7 for details on preparing for klevu js overriding within the json response object the ratings are defined with a type value of "rating" this value is used during template display logic to render specific elements for ratings and review count json response example "filters" \[ { "key" "rating", "label" "customer reviews", "type" "rating", "options" \[ { "count" 28, "name" "5", "value" "4 51 5 5", "selected" true } ] }, template override example this example overrides the klevulandingproductrating template to display some custom text based on the item's rating value see set template docid 6yvx9naw6ax68wygucob7 for details on preparing for klevu js templates for overriding javascript