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 configuration

Describes how to configure recommendations based on tracking requests.

If the Recommendations product were enabled for the current page, you can request that additional product attributes for the product be supplied in the smartRecs response.

Name Description and usage
smartRecs  
  showAttributes [Optional]

Controls which attributes to show in the smartRecs callback.

An array 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 be rendered. See Rendering Recommendations.

If set to false, an additional API call needs to be made to inform Optimizely of the IDs of recommendations that were rendered.

Recommendations configuration example

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

{
      "type"        : "product",
      "ip"	        : "10.42.37.139",
      "session"     : "123456789012|a1b2c3d4e5A6B7C8D9E0f1g2h3i4j5F1G2H3I4J5k1l",
      "cuid"        : "09876543210|Z0Y9X8W7V6z5y4x3w2v1U0T9S8R7Q6u5t4s3r2q1P0O",
      "site"        : "retailer",
      "clientToken" : "1234abcd5678",
      "channel"     : "web",
      "lang"        : "en-gb",
      "currentURI"	: "www.retailer.com/product/RC123.html",
      "previousURI" : "www.retailer.com/home",
      "userAgent"   : "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
      "smartRecs"   : {
                        "showAttributes": ["*"]
                      },
      "product"     : {
                        "refCode": "RC123"
                      }
    }

For the callback to contain only the attribute "colour" for each recommended product, send the following.

{
      "type"        : "product",
      "ip"          : "10.42.37.139",
      "session"     : "123456789012|a1b2c3d4e5A6B7C8D9E0f1g2h3i4j5F1G2H3I4J5k1l",
      "cuid"        : "09876543210|Z0Y9X8W7V6z5y4x3w2v1U0T9S8R7Q6u5t4s3r2q1P0O",
      "site"        : "retailer",
      "clientToken" : "1234abcd5678",
      "channel"     : "web",
      "lang"        : "en-gb",
      "currentURI"  : "www.retailer.com/product/RC123.html",
      "previousURI" : "www.retailer.com/home",
      "userAgent"   : "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
      "smartRecs"   : {
                        "showAttributes": ["colour"]
                      },
      "product"     : {
                        "refCode": "RC123"
                      }
    }