Using response tokens

  1. Ensure that you are using Platform Web SDK version 2.6.0 (or later) or at.js version 1.1 (or later).

    For more information:

  2. In Target, click Administration > Response Tokens.

  3. Activate the desired response tokens, such as activity.id and offer.id.

    The following parameters are available by default:

    TypeParameterNotes
    Built-in Profilesprofile.activeActivitiesReturns an array of the activityIds the visitor is qualified for. It increments as users are qualified. For example, on a page with two Target requests delivering two different activities, the second request includes both activities.
    profile.isFirstSessionReturns “true” or “false.”
    profile.isNewSessionReturns “true” or “false.”
    profile.daysSinceLastVisitReturns the number of days since the visitor’s last visit.
    profile.tntIdReturns the visitor’s tntID
    profile.marketingCloudVisitorIdReturns the visitor’s Experience Cloud Visitor ID.
    profile.thirdPartyIdReturns the visitor’s third-party ID.
    profile.categoryAffinityReturns the visitor’s favorite category.
    profile.categoryAffinitiesReturns an array of the visitor’s top 5 categories as strings.
    Activityactivity.name
    activity.id
    experience.name
    experience.id
    offer.name
    offer.id
    Details of the current activity.
    Note that values for offer parameters are evaluated on the experience level.
    Geogeo.country
    geo.state
    geo.city
    geo.zip
    geo.dma
    geo.domainName
    geo.ispName
    geo.connectionSpeed
    geo.mobileCarrier
    See Geo for more information about using geo targeting in activities.
    Traffic Allocation Method
    (Applies to Auto-Target and Automated Personalization activities only.)
    experience.trafficAllocationIdReturns 0 if a visitor received an experience from being in “control” traffic and 1 if a visitor received an experience from the “targeted” traffic distribution.
    experience.trafficAllocationTypeReturn “control” or “targeted.”

    User profile attributes and Customer Attributes also display in the list.

    NOTE
    Parameters with special characters do not display in the list. Only alphanumeric characters and underscores are supported.
  4. (Conditional) To use a profile parameter as a response token, but the parameter has not been passed through a Target request and, thus, has not loaded into the Target UI, you can use the Add Response Token button to add the profile to the UI.

    Click Add Response Token, provide the token name, then click Activate.

  5. Create an activity.

Listen for responses and read response tokens

The process you use to listen for Target responses and read response tokens differs depending on whether you have a Platform Web SDK or at.js implementation.

Adobe Experience Platform Web SDK badge Platform Web SDK using the Handle object class

Use the Handle object class, which has a meta data object and a data object to listen for Target responses and read the response tokens.

The following response example adds a Platform Web SDK custom event handler directly to the HTML page (the table explains objects used in the code):

ObjectInformation
Type – Personalization.decisionWhether the decision was made by the Target or Offer Decisioning provider.
DecisionProvider – TGTTGT-Target. Target provides the response token metadata and values to the page.
MetaMetadata that is passed to the page.
DataValues of the metadata passed to the page.
<html>

<head>
 ...
 <script src="alloy.js"></script>
 <script>
  {
   "requestId": "4d0a7cfd-952c-408c-b3b8-438edc38250a",
   "handle": [{
    "type": "personalization:decisions",
    "payload": [{
     "id": "....",
     "scope": "__view__",
     "scopeDetails": {
      "decisionProvider": "TGT",
      "activity": {
       "id": "..."
      },
      "experience": {
       "id": "...."
      }
     },
     "items": [{
      "id": "123",
      "schema": "https://ns.adobe.com/personalization/dom-action",
      "meta": {
       "activity.id": "...",
       "activity.name": "...",
       "profile.foo": "...",
       "profile.bar": "..."
      },
      "data": {
       "id": "123",
       "type": "setHtml",
       "selector": "#foo",
       "prehidingSelector": "#foo",
       "content": "<div>Hello world</div>"
      }
     }]
    }]
   }]
  }
  });
 </script>
</head>

<body>
 ...
</body>

</html>