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

JSONArray callback example

Shows an example of a JSONArray callback.

The following example shows the JSONArray callback for a widget with full product details, default behavior and when recContent is omitted or has the value full:

[{
      "widget"   : "homejson",
      "alias"    : "homewidget",
      "position" : "homebottom", 
      "recs"     : [{
        "img"      : "http://m.retailer.com/showimg.php?id=2086&size=tiny",
        "title"    : "Mighty Water Bottle: Blue",
        "url"      : "http://m.retailer.com/product/mighty-water-bottle-blue",
        "refCode"  : "mighty-water-bottle-blue",
        "location" : "en-gb",
        "prices"   : {
          "GBP" : {
            "unitPrice" : 4.95,
            "salePrice" : 3.95
          }
        },
        "id"       : 32720906612,
      }, 
      {
        ...more products
      }]
    }]

The following example shows the JSONArray callback for a widget with the recContent property set to refCodeOnly:

[
      "widget"   : "homejson",
      "alias"    : "homewidget",
      "position" : "homebottom", 
      "recs"     : [
        {"id" : 17994255560, "refCode" : "DVD-SPEED2"},
        {"id" : 17994255576, "refCode" : "DVD-TSAB"}       ]
    ]