Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Recommendations callback

Describes the callbacks used for product recommendations.

Optimizely returns product recommendations in the form of a JavaScript callback method. When the product recommendations are ready, they are passed to this callback function in the form of JSON data.

var PeeriusCallbacks={
      smartRecs:function(jsonData) {
        // implementation ….
      }
    }

The jsonData parameter is a list of recommendation widget elements that have the following properties.

Name Description and usage
widget [String]

Name of widget.

Use for information only because this varies during A/B testing.

To determine where to place a widget on the page, use the position attribute, below.
alias [String]

Alias of the widget.

This is used internally by Optimizely Personalization. It should be used for information only.
position [String]

Name of the page position for this widget.

This attribute should be used to determine the page position in which to show the widget. It needs to be a unique ID.

This value is stable and should be used to reference (rather than widget).
  recs A list of recommendations
    img [String]

URL of the product image.
    title [String]

Product title.
    url [String]

URL to the item's product page.
    refCode [String]

Product reference code.
    prices A map in which
  • the key is the currency name (such as USD, GBP, and so on)
  • the value is a map with unitPrice and salePrice properties.
      unitPrice [Number]

The item's price per unit.
      salePrice [Number]

The item's sale price.
   

id

[64bit Number]

Recommendation id.

This is used for marking clicks. See Marking clicks.
    attributes A list of attributes and their values.

Attributes requested in the tracking request. See Additional attributes in recommendations.