Create JSON offers

Create JSON offers in the Offer Library in Adobe Target for use in the Form-Based Experience Composer.

JSON offers can be used in form-based activities whereby enabling use cases where Target decisioning is required to send an offer in JSON format for consumption in SPA framework or server-side integrations.

JSON considerations

Consider the following information as you work with JSON offers:

  • JSON offers are currently available only for A/B Test, Automated Personalization (AP), and Experience Targeting (XT) activities.
  • JSON offers can be used in form-based activities only.
  • JSON offer can be retrieved directly when you are using the Server Side APIs and Mobile Node.js, Java, .NET, and Python SDKs.
  • In the browser, JSON offers can be retrieved ONLY via at.js 1.2.3 (or later) and using getOffer() by filtering actions using the setJson action.
  • JSON offers are delivered as native JSON objects rather than as strings. Consumers of these objects are no longer required to handle objects as strings and convert them to JSON objects.
  • JSON offers are not applied automatically as opposed to other offers (such as HTML offers) because JSON offers are non-visual offers. Developers must write code to explicitly get the offer using getOffer().

Create a JSON offer section_BB9C72D59DEA4EFB97A906AE7569AD7A

  1. Click Offers > Code Offers.

    Offers > Code Offers tab

  2. Click Create > JSON Offer.

    offer-json image

  3. Type an offer name.

  4. Type or paste your JSON code in the Code box.

  5. Click Save.

JSON example section_A54F7BB2B55D4B7ABCD5002E0C72D8C9

JSON offers are supported only in activities created using the Form-Based Experience Composer. Currently the only way to be able to use JSON offers is via direct API/SDK calls.

Here is an example:

adobe.target.getOffer({
  mbox: "some-mbox",
  success: function(actions) {
    console.log('Success', actions);
  },
  error: function(status, error) {
    console.log('Error', status, error);
  }
});

The actions passed to success callback is an array of object. Assuming that we have a single JSON offer, that has this content:

{
  "demo": {"a": 1, "b": 2}
}

The actions array has this structure:

[
 {
   action: "setJson",
   content: [{
     "demo": {"a": 1, "b": 2}
   }]
 }
]

To extract the JSON offer, you iterate through actions and find the action with the setJson action, and then iterate through the content array.

Use case section_85B07907B51A43239C8E3498EF58B1E5

Let’s say the following JSON offer gets delivered to your web page:

{
    "_id": "5a65d24d8fafc966921e9169",
    "index": 0,
    "guid": "7c006504-c6f7-468d-a46f-f72531ea454c",
    "isActive": true,
    "balance": "$2,075.06",
    "picture": "https://placehold.it/32x32",
    "tags": [
      "esse",
      "commodo",
      "excepteur",
    ],
    "friends": [
      {
        "id": 0,
        "name": "Carla Lyons"
      },
      {
        "id": 1,
        "name": "Ollie Mooney"
      },
    ],
    "greeting": "Hello, Stephenson Fernandez! You have 4 unread messages.",
    "favoriteFruit": "strawberry"
}

The following code shows how to access the “greeting” attribute:

adobe.target.getOffer({
  "mbox": "name_of_mbox",
  "params": {},
  "success": function(offer) {
        console.log(offer[0].content[0].greeting);
  },
  "error": function(status, error) {
      console.log('Error', status, error);
  }
});

JSON offer example using Real-time CDP Profile Attributes

Real-time CDP Profile Attributes can be shared with Target for use in HTML and JSON offers.

For more information, see Share Real-time CDP Profile Attributes with Target.

Filtering offers by the JSON offer type section_52533555BCE6420C8A95EB4EB8907BDE

You can filter the Offers library by the JSON offer type by clicking the Type drop-down list, then by selecting the JSON checkbox.

offer-json-filter image

recommendation-more-help
3d9ad939-5908-4b30-aac1-a4ad253cd654