HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Request additional attributes in product recommendations

Shows how to request additional attributes when product recommendations are enabled.

If the Optimizely Product Recommendations product was enabled for the current page, you can request that additional product attributes (such as star ratings) are supplied in the smartRecs callback.

Name Description and usage

smartRecs

 
  showAttributes [Optional]

Controls which attributes to show in the smartRecs callback.
 
A comma-separated list of attribute names to send in the smartRecs callback. If this property is not supplied, no attributes are sent. If this property is set to "*", all available attributes are sent.
  markRecsAsShown [Optional]

Whether all recommendations sent as the response are rendered.

This must be included if a subset of recommendations sent as the response is rendered on the front end of your site/application.

Default is true; that is, all recommendations in the response are assumed to have been rendered.

If set to false, an additional API call needs to be made to inform Optimizely of the IDs of recommendations that have been rendered. See Impression tracking.

For example, on a product page tracking request, to show all attributes for the recommended products, send the following.

<script> 
    PeeriusCallbacks.track={ 
     	type        : "product",
      lang        : "en-gb",
      "smartRecs" : {
        "showAttributes" : ["*"]
      },
      product     : {
        refCode:"PROD500"
      }
    } 
    </script>

If you want the callback to contain only the attribute "starrating", for each recommended product, send the following.

<script> 
    PeeriusCallbacks.track={
      type        : "product",
      lang        : "en-gb",
      "smartRecs" : {
        "showAttributes" : ["starrating"]
      },
      product     : {
        refCode:"PROD500"
      }
    } 
</script>