从Adobe Target返回的个性化内容包括 响应令牌,其中包含有关活动、选件、体验、用户配置文件、地理信息等的详细信息。 这些详细信息可与第三方工具共享或用于调试。 可在Adobe Target用户界面中配置响应令牌。
要访问任何个性化内容,请在发送事件时提供回调函数。 SDK收到来自服务器的成功响应后,将调用此回调。 将为您的回调提供 result
对象,其中可能包含 propositions
包含任何返回的个性化内容的属性。 以下是提供回调函数的示例。
alloy("sendEvent", {
renderDecisions: true,
xdm: {}
}).then(function(result) {
if (result.propositions) {
// Manually render propositions
}
});
在此示例中, result.propositions
如果存在,则是一个数组,其中包含与事件相关的个性化建议。 请参阅 呈现个性化内容 ,以了解有关 result.propositions
.
假设您要从Web SDK自动渲染的所有建议中收集所有活动名称,并将它们推入单个数组中。 然后,您可以将单个阵列发送给第三方。 在本例中:
result
对象。meta
属性,它是一个包含响应令牌的对象。您的代码如下所示:
alloy("sendEvent", {
renderDecisions: true,
xdm: {}
}).then(function(result) {
var activityNames = [];
propositions.forEach(function(proposition) {
if (proposition.renderAttempted) {
proposition.items.forEach(function(item) {
if (item.meta) {
// item.meta contains the response tokens.
var activityName = item.meta["activity.name"];
// Ignore duplicates
if (activityNames.indexOf(activityName) === -1) {
activityNames.push(activityName);
}
}
});
}
});
// Now that activity names are in an array,
// you can send them to a third party or use
// them in some other way.
});