Response tokens let you automatically output information specific to Adobe Target to your brand’s web page. This information can include details about the activity, offer, experience, user profile, geo information, and more. These details provide extra response data to share with internal or 3rd-party tools or to use for debugging.
Response tokens let you choose which variables (in key value pairs) to use and then enable them to be sent as part of a Target response. You enable a variable using the switch and the variable is sent with Target responses, which can be validated in network calls. Response tokens also work in Preview mode.
A key difference between plug-ins and response tokens is that plug-ins deliver JavaScript to the page that executes upon delivery. Response tokens, however, deliver an object that can then be read and acted upon using event listeners. The response token approach is safer and allows for easier development and maintenance of 3rd-party integrations.
NOTE
Response tokens are available with at.js version 1.1 or later.
Ensure that you are using Platform Web SDK version 2.6.0 or later. For information about downloading the latest version of Platform Web SDK, see Install the SDK in the Platform Web SDK overview guide. For information about new functionality in each version of the Platform Web SDK, see Release notes in the Platform Web SDK overview guide.
Ensure that you are using at.js version 1.1 or later. For information about downloading the latest version of at.js, see Download at.js. For information about new functionality in each version of at.js, see at.js Version Details. Customers using at.js are encouraged to use response tokens and move away from plugins. Some plugins that rely on internal methods that existed in mbox.js (now deprecated), but not in at.js, are delivered but fail.
Using response tokens
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:
Platform Web SDK: See Install the SDK in the Platform Web SDK overview guide.
In Target, click Administration > Response Tokens.
Activate the desired response tokens, such as activity.id and offer.id.
The following parameters are available by default:
Type
Parameter
Notes
Built-in Profiles
profile.activeActivities
Returns 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.isFirstSession
Returns “true” or “false.”
profile.isNewSession
Returns “true” or “false.”
profile.daysSinceLastVisit
Returns the number of days since the visitor’s last visit.
profile.tntId
Returns the visitor’s tntID
profile.marketingCloudVisitorId
Returns the visitor’s Experience Cloud Visitor ID.
profile.thirdPartyId
Returns the visitor’s third-party ID.
profile.categoryAffinity
Returns the visitor’s favorite category.
profile.categoryAffinities
Returns an array of the visitor’s top 5 categories as strings.
See Geo for more information about using geo targeting in activities.
Traffic Allocation Method (Applies to Auto-Target and Automated Personalization activities only.)
experience.trafficAllocationId
Returns 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.trafficAllocationType
Return “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.
(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.
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.
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):
Object
Information
Type – Personalization.decision
Whether the decision was made by the Target or Offer Decisioning provider.
DecisionProvider – TGT
TGT-Target. Target provides the response token metadata and values to the page.
Which role is required to activate or deactivate response tokens?
Response tokens can be activated or deactivated only by users with the Target Administrator role.
What happens if I am running Platform Web SDK 2.6.0 (or earlier)?
You do not have access to response tokens.
What happens if I am running at.js 1.0 (or earlier)?
You see the response tokens, but at.js cannot use them.
Can I have both Target Classic plugins and response tokens active at the same time?
Plugins and response tokens are available in parallel; however, plugins will be deprecated in the future.
Are response tokens delivered through all Target responses or only through Target responses delivering an activity?
Response tokens are delivered only through Target responses delivering an activity.
My Target Classic plugin included JavaScript. How do I replicate its functionality using response tokens?
When migrating to response tokens, this type of JavaScript must be kept in your codebase or tag management solution. You can trigger this code using Platform Web SDK or at.js custom events and pass the response token values to your JavaScript functions.
Why does my profile/Customer Attributes parameter not display in the response tokens list?
Target normally refreshes parameters every 15 minutes. This refresh depends on user action and data is refreshed only when you view the response tokens page. If your parameters do not display in the response token list, Target has not yet refreshed the data.
Also, if your parameter contains anything but non-alphanumeric characters or any symbol other than underscores, the parameter does not appear in the list. Currently, only alphanumeric and underscore characters are supported.
Does the response token still deliver content if it uses a deleted profile script or a profile parameter?
Response tokens extract information from user profiles and then deliver that information. If you delete a profile script or parameter, that does not mean that the information has been removed from the user profiles. The user profiles still have data corresponding to the profile script. The response token continues delivering the content. For users that do not have that information saved in their profiles, or for new visitors, that token is not delivered because the data is not present in their profiles.
Target does not toggle off the token automatically. If you delete a profile script and no longer want the token to be delivered, you must toggle off the token yourself.
I renamed my profile script, but why is the token using that script still active with the old name?
As mentioned above, response tokens work on the profile information saved for users. Even though you renamed your profile script, users who have visited your website have the old profile script value saved in their profiles. The token continues to pick up the old value that is already saved in the user profiles. If you now want to deliver content on the new name, you must toggle off the previous token and toggle on the new token.
If my attributes have changed, when are they be removed from the list?
Target performs a refresh of attributes at regular intervals. Any attribute that is not toggled on is removed during the next refresh. However, if you have an attribute that was toggled on and has been removed, that script is not removed from the attribute list until you toggle it off. As an example, you removed a profile script that was used as a token. Target removes only the toggled-off attributes from the list when they are deleted or renamed.
Send data to Google Analytics
The following sections describe how to send Target data to Google Analytics 4. Data sent by response tokens can also be sent to other other 3rd-party integrations.
Sending data to Google Analytics via Platform Web SDK
Google Analytics can be sent data via Platform Web SDK version 2.6.0 (or later) by adding the following code in the HTML page.
NOTE
Make sure the response token key value pair are under the alloy("sendEvent" object.
Google Analytics can be sent data via at.js by adding the following code in the HTML page:
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
<script type="text/javascript">
document.addEventListener(adobe.target.event.REQUEST_SUCCEEDED, function(e) {
var tokens = e.detail.responseTokens;
if (isEmpty(tokens)) {
return;
}
var activityNames = [];
var experienceNames = [];
var uniqueTokens = distinct(tokens);
uniqueTokens.forEach(function(token) {
activityNames.push(token["activity.name"]);
experienceNames.push(token["experience.name"]);
});
gtag('config', 'TAG_ID');
gtag('event', 'action_name', {'eventCategory': 'target',
'eventAction': experienceNames, 'eventLabel': activityNames
});
});
function isEmpty(val) {
return (val === undefined || val == null || val.length <= 0) ? true : false;
}
function key(obj) {
return Object.keys(obj)
.map(function(k) { return k + "" + obj[k]; })
.join("");
}
function distinct(arr) {
var result = arr.reduce(function(acc, e) {
acc[key(e)] = e;
return acc;
}, {});
return Object.keys(result)
.map(function(k) { return result[k]; });
}
</script>
Debugging
The following sections provide information about debugging response tokens:
Google Analytics and debugging
The following code lets you debug using Google Analytics:
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
<script type="text/javascript">
document.addEventListener(adobe.target.event.REQUEST_SUCCEEDED, function(e) {
var tokens = e.detail.responseTokens;
if (isEmpty(tokens)) {
return;
}
var activityNames = [];
var experienceNames = [];
var uniqueTokens = distinct(tokens);
uniqueTokens.forEach(function(token) {
activityNames.push(token["activity.name"]);
experienceNames.push(token["experience.name"]);
});
gtag('config', 'TAG_ID');
gtag('event', 'action_name', {'eventCategory': 'target',
'eventAction': experienceNames, 'eventLabel': activityNames
});
});
function isEmpty(val) {
return (val === undefined || val == null || val.length <= 0) ? true : false;
}
function key(obj) {
return Object.keys(obj)
.map(function(k) { return k + "" + obj[k]; })
.join("");
}
function distinct(arr) {
var result = arr.reduce(function(acc, e) {
acc[key(e)] = e;
return acc;
}, {});
return Object.keys(result)
.map(function(k) { return result[k]; });
}
</script>
Debugging using the equivalent of the ttMeta plugin
The equivalent of the ttMeta plugin for debugging purposes can be created by adding following code to HTML page:
<script type="text/javascript" >
document.addEventListener(adobe.target.event.REQUEST_SUCCEEDED, function (e) {
window.ttMETA= typeof(window.ttMETA)!="undefined" ? window.ttMETA : [];
var tokens=e.detail.responseTokens;
if (isEmpty(tokens)) {
return;
}
var uniqueTokens = distinct(tokens);
uniqueTokens.forEach(function(token) {
window.ttMETA.push({
'CampaignName': token["activity.name"],
'CampaignId' : token["activity.id"],
'RecipeName': token["experience.name"],
'RecipeId': token["experience.id"],
'OfferId': token["offer.id"],
'OfferName': token["offer.name"],
'MboxName': e.detail.mbox});
console.log(ttMETA);
});
});
function isEmpty(val){
return (val === undefined || val == null || val.length <= 0) ? true : false;
}
function key(obj) {
return Object.keys(obj)
.map(function(k) { return k + "" + obj[k]; })
.join("");
}
function distinct(arr) {
var result = arr.reduce(function(acc, e) {
acc[key(e)] = e;
return acc;
}, {});
return Object.keys(result)
.map(function(k) { return result[k]; });
}
</script>
Training Video: Response Tokens and at.js Custom Events
The following video explains how to use response tokens and at.js custom events to share profile information from Target to 3rd-party systems.
NOTE
The Target Administration menu UI (formerly Setup) has been redesigned to provide improved performance, reduce the maintenance time required when releasing new features, and to improve the user experience across the product. The information in the following video is correct; however, options are in slightly different locations.
The video mentions option.name and option.id, which have been replaced with offer.name and offer.id, respectively.