Examples

Adding parameters with getOffer() and using applyOffer() for success-handling:

adobe.target.getOffer({
  "mbox": "target-global-mbox",
  "params": {
     "a": 1,
     "b": 2
  },
  "success": function(offer) {
        adobe.target.applyOffer( {
           "mbox": "target-global-mbox",
           "offer": offer
        } );
  },
  "error": function(status, error) {
      console.log('Error', status, error);
  }
});

Adding parameters and profile parameters with getOffer() and using applyOffer() for success-handling:

adobe.target.getOffer({
  "mbox": "target-global-mbox",
  "params": {
     "a": 1,
     "b": 2,
     "profile.age": 27,
     "profile.gender": "male"
  },
  "success": function(offer) {
        adobe.target.applyOffer( {
           "mbox": "target-global-mbox",
           "offer": offer
        } );
  },
  "error": function(status, error) {
      console.log('Error', status, error);
  }
});

Using custom timeout and custom success-handling with getOffer():

“YOUR_OWN_CUSTOM_HANDLING_FUNCTION” is a placeholder for a function the customer would define.

adobe.target.getOffer({
  "mbox": "target-global-mbox",
  "success": function(offer) {
    YOUR_OWN_CUSTOM_HANDLING_FUNCTION(offer);
  },
  "error": function(status, error) {
    console.log('Error', status, error);
  },
  "timeout": 2000
});

Responses

The response parameter passed to the success callback will be an array of actions. An action is an object that usually has the following format:

NameTypeDescription
actionStringType of action to be applied to the identified element.
selectorStingRepresents a Sizzle selector.
cssSelectorStringDOM native selector, used for element pre-hiding.
contentStringThe content to be applied to the identified element.

Example

{
    "sessionId": "1444512212156-384616",
    "tntId": "1444512212156-384616.17_35",
    "offers": [{
        "plugins": ["<script type=\"text/javascript\">\r\n/*mboxHighlight+ (1of2) v1 ==> Response Plugin*/\r\nwindow.ttMETA=(typeof(window.ttMETA)!='undefined')?window.ttMETA:[];window.ttMETA.push({'mbox':'target-global-mbox','campaign':'at: redirect ootb','experience':'Experience B','offer':'/at_redirect_ootb/experiences/1/pages/0/1442082890250'});window.ttMBX=function(x){var mbxList=[];for(i=0;i<ttMETA.length;i++){if(ttMETA[i].mbox==x.getName()){mbxList.push(ttMETA[i])}}return mbxList[x.getId()]}\r\n</script>"],
        "actions": {
            "content": [{
                "passMboxSession": false,
                "selector": "body",
                "action": "redirect",
                "url": "https://example.com/04.html",
                "includeAllUrlParameters": true
            }]
        }
    }]
}

Error Responses

The “status” and “error” parameters passed to the error callback will have the following format:

NameTypeDescription
statusString

Represents the error status. This parameter can have the following values:

  • timeout: Indicates that the request timed out.
  • parseerror: Indicates that the response could not be parsed, for example if we receive HTML or plain text instead of JSON.
  • error: Indicates a general error like we received HTTP status different from 200 OK
errorStringContains additional data like exception message or anything else that might be useful for troubleshooting.
Previous pageat.js functions overview
Next pageadobe.target.getOffers() - at.js 2.x

Target


Personalization & Experiementation Excellence with Recommendations and AI

Adobe Customer Success Webinars

Tuesday, Mar 4, 4:00 PM UTC

Adobe Target innovations, including GenAI, and best practices on AI-powered personalization and experimentation at scale.

Register

Connect with Experience League at Summit!

Get front-row access to top sessions, hands-on activities, and networking—wherever you are!

Learn more