Handling command responses

Some Web SDK commands can return an object containing data potentially useful to your organization. You can choose what to do with that data, if desired. Command responses are valuable for propositions and destinations, as they require Edge Network data to effectively work.

Command responses use JavaScript promises, acting as a proxy for a value that is not known when the promise is created. Once the value is known, the promise is “resolved” with the value.

Handle command responses using the Web SDK tag extension

Create a rule that subscribes to the Send event complete event as part of a rule.

  1. Log in to experience.adobe.com using your Adobe ID credentials.
  2. Navigate to Data Collection > Tags.
  3. Select the desired tag property.
  4. Navigate to Rules, then select the desired rule.
  5. Under Events, select an existing event or create an event.
  6. Set the Extension dropdown field to Adobe Experience Platform Web SDK, and set the Event Type to Send event complete.
  7. Click Keep Changes, then run your publishing workflow.

You can then include the actions Apply propositions or Apply response to this rule.

  1. When viewing the above created or edited rule, select an existing action or create an action.
  2. Set the Extension dropdown field to Adobe Experience Platform Web SDK, and set the Action Type to Apply propositions or Apply response, depending on the desired behavior.
  3. Set the action’s desired fields, then click Keep Changes.

Handle command responses using the Web SDK JavaScript library

Use the then and catch methods to determine when a command succeeds or fails. You can omit either then or catch if their purposes are not important to your implementation.

alloy("sendEvent", {
  "xdm": {
    "commerce": {
      "order": {
        "purchaseID": "a8g784hjq1mnp3",
        "purchaseOrderNumber": "VAU3123",
        "currencyCode": "USD",
        "priceTotal": 999.98
}).then(function(result) {
    console.log("The sendEvent command succeeded.");
  .catch(function(error) {
    console.log("The sendEvent command failed.");

All promises returned from commands use a result object. For example, you can obtain library info from the result object using the getLibraryInfo command:

  .then(function(result) {

The contents of this result object depend on a combination of what command that you use and the user’s consent. If a user has not given their consent for a particular purpose, the response object only contains information that can be provided in the context of what the user has consented to.