Expand my Community achievements bar.

Get ready! An upgraded Experience League Community experience is coming in January.
Submissions are now open for the 2026 Adobe Experience Maker Awards
SOLVED

getOffer() Code - WebSDK vs AT.JS

Avatar

Level 2

Hello, 

 

I was using at.js to get recommendation offers for my website. However, I was using the following code with at.js and I am not sure how to convert it to use webSDK.

 

### code ###
adobe.target.getOffer({ "mbox": "DemoBox2", "params":{ "entity.id":"target-global-mbox" }, "success": function(offer) { console.log("Result: "+offer[0].content); }, "error": function(status, error) { console.log('Error', status, error); } });

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @SoufianeLa , 

In webSdk, you can use sendEvent command to request offers (propositions) for one or more locations (scopes). An alternate code for using getOffer() and applyOffer() in webSdk would be : 

 alloy("sendEvent", {
  "decisionScopes": ["Homepage_regional_mbox"]
}).then(function(result) {
  var retrievedPropositions = result.propositions;

  // Render offer (proposition) to the #hero-banner selector by supplying extra metadata
  return alloy("applyPropositions", {
    "propositions": retrievedPropositions,
    "metadata": {
      // Specify each regional mbox or scope name along with a selector and actionType
      "Homepage_regional_mbox": {
        "selector": ".tracking-tight",
        "actionType": "replaceHtml"
      }
    }
  }).then(function(applyPropositionsResult) {
    var renderedPropositions = applyPropositionsResult.propositions;

    // Send the display notifications via sendEvent command
    alloy("sendEvent", {
      "xdm": {
        "eventType": "decisioning.propositionDisplay",
        "_experience": {
          "decisioning": {
            "propositions": renderedPropositions
          }
        }
      }
    });
  });
});


For more such codes related to at.js VS webSDK , you can feel free to use this cheatsheet : https://dexata.co/adobe-target-commands-profilescripts-cheatsheet/  

Best Regards,
Vaibhav Mathur

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @SoufianeLa , 

In webSdk, you can use sendEvent command to request offers (propositions) for one or more locations (scopes). An alternate code for using getOffer() and applyOffer() in webSdk would be : 

 alloy("sendEvent", {
  "decisionScopes": ["Homepage_regional_mbox"]
}).then(function(result) {
  var retrievedPropositions = result.propositions;

  // Render offer (proposition) to the #hero-banner selector by supplying extra metadata
  return alloy("applyPropositions", {
    "propositions": retrievedPropositions,
    "metadata": {
      // Specify each regional mbox or scope name along with a selector and actionType
      "Homepage_regional_mbox": {
        "selector": ".tracking-tight",
        "actionType": "replaceHtml"
      }
    }
  }).then(function(applyPropositionsResult) {
    var renderedPropositions = applyPropositionsResult.propositions;

    // Send the display notifications via sendEvent command
    alloy("sendEvent", {
      "xdm": {
        "eventType": "decisioning.propositionDisplay",
        "_experience": {
          "decisioning": {
            "propositions": renderedPropositions
          }
        }
      }
    });
  });
});


For more such codes related to at.js VS webSDK , you can feel free to use this cheatsheet : https://dexata.co/adobe-target-commands-profilescripts-cheatsheet/  

Best Regards,
Vaibhav Mathur