ABCDEF
1
Adobe Target - Commands - Profile Script Cheatsheet
2
ActivityFunction/CommandVariationSyntax at.jsWebSdk Alternate Syntax WebSdk
3
Adobe Exp Cloud SDK - Taregt APIsMobile App PerosonalisationList of Target APIs for Mobile SDK
4
Pass params to mbox before a single Adobe Target calltargetPageParams()1. Ampersand-delimited list (values must be URL encoded)function targetPageParams(){
return "param1=value1&param2=value2&p3=hello%20world";
}
Custom mbox parameters must be passed as XDM data with the sendEvent command. It is important to ensure that the XDM schema includes all fields required for your Target implementation.window.alloy("sendEvent", {
"xdm": {
"web": {
"webPageDetails": {
"targetcustomparameter":"xyz"
}
}
}
});
5
Pass params to mbox before Adobe Target calltargetPageParams()2. Array (values do not need to be URL encoded)targetPageParams = function(){
return ["a=1", "b=2", "c=hello world"];
};
6
Pass params to mbox before Adobe Target calltargetPageParams()3. JSON (values do not need to be URL encoded)targetPageParams = function() {
return {
"a": 1,
"b": 2,
"profile": {
"age": 26,
"country": {
"city": "San Francisco"
}
}
};
};
7
Pass params to all mbox calls on a pagetargetPageParamsAll()Variations same as targetPageParams()targetPageParams = function() {
return {
"a": 1,
"b": 2,
"profile": {
"age": 26,
"country": {
"city": "San Francisco"
}
}
};
};
8
Pass params to Adobe Target when an event occurstrackEvent()Variations same as targetPageParams()adobe.target.trackEvent({
"mbox": "clicked-cta",
"params": {
"param1": "value1"
}
});
We can use the same sendEvent function to send interact calls through javascript from Target.
Note : Use "renderDecisions" = false
<script>
window.alloy("sendEvent", {
"renderDecisions": false,
decisionScopes: ["__view__"],
"xdm": {
"web": {
"webPageDetails": {
"paramName": "test"
}
}
}
})
</script>
9
Passing Profile Attributes to the HTML offerprofile attributeAdobe Target Passing Dynamic Attributes
10
Read a Target attribute in Experience offer code to dynamically populate experienceprofile attributevar a = “${user.YOUR_PROFILE_ATTRIBUTE}”;
11
Read a Target attribute in Experience offer code to dynamically populate experiencedefining a default valuevar a = '${user.YOUR_PROFILE_ATTRIBUTE default="DEFAULT_VALUE"}';
12
Getting and applying offer-codegetOffer() and applyOffer()adobe.target.getOffer({
"mbox": "target-global-mbox",
"params":{
"a": "b",
"x": "y"
},
"success": function(offer) {
adobe.target.applyOffer( {
"mbox": "target-global-mbox",
"offer": offer
} );
},
"error": function(status, error) {
console.log('Error', status, error);
}
});
In web SDK example using sendEvent
1. Execute sendEvent command to request offers (propositions) for one or more locations (scopes)
2. Execute applyPropositions command with metadata object which supplies instructions for how to apply content to the page for each scope
3. Execute sendEvent command with eventType of decisioning.propositionDisplay to track an impression
4. Alternate to getOffer can be retrievedPropositions and alternate to applyOffer can be renderedPropositions

alloy("sendEvent", {
"decisionScopes": ["Homepage_regional_mbox"]
}).then(function(result) {
var retrievedPropositions = result.propositions;

// Render offer (proposition) to the #hero-banner selector by supplying extra metadata
return alloy("applyPropositions", {
"propositions": retrievedPropositions,
"metadata": {
// Specify each regional mbox or scope name along with a selector and actionType
"Homepage_regional_mbox": {
"selector": ".tracking-tight",
"actionType": "replaceHtml"
}
}
}).then(function(applyPropositionsResult) {
var renderedPropositions = applyPropositionsResult.propositions;

// Send the display notifications via sendEvent command
alloy("sendEvent", {
"xdm": {
"eventType": "decisioning.propositionDisplay",
"_experience": {
"decisioning": {
"propositions": renderedPropositions
}
}
}
});
});
});
13
Getting and applying multiple offer-codesgetOffers()Using with prefetchadobe.target.getOffers({
request: {
prefetch: {
mboxes: [
{
index: 0,
name: "mbox1",
},
{
index: 1,
name: "mbox2",
parameters:
{
"a": 2,
"b": 3
}
}
]
},
property:{token:""}
}
})
.then(response => {
// get all mboxes from response
const mboxes = response.prefetch.mboxes;
let count = 1;
mboxes.forEach(el => {
adobe.target.applyOffers({
response: {
prefetch: {
mboxes: [el]
}
}
});
count += 1;
});
});
In web SDK example using sendEvent
1. Execute sendEvent command to request offers (propositions) for one or more locations (scopes)
2. Execute applyPropositions command with metadata object which supplies instructions for how to apply content to the page for each scope
3. Execute sendEvent command with eventType of decisioning.propositionDisplay to track an impression
4. Alternate to getOffer can be retrievedPropositions and alternate to applyOffer can be renderedPropositions
alloy("sendEvent", {
"decisionScopes": ["Homepage_regional_mbox","Homepage_regional_mbox1"]
}).then(function(result) {
var retrievedPropositions = result.propositions;

// Render offer (proposition) to the #hero-banner selector by supplying extra metadata
return alloy("applyPropositions", {
"propositions": retrievedPropositions,
"metadata": {
// Specify each regional mbox or scope name along with a selector and actionType
"Homepage_regional_mbox1": {
"selector": ".text-lg",
"actionType": "replaceHtml"
},
"Homepage_regional_mbox": {
"selector": ".shadow-sm",
"actionType": "replaceHtml"
}
}
}).then(function(applyPropositionsResult) {
var renderedPropositions = applyPropositionsResult.propositions;

// Send the display notifications via sendEvent command
alloy("sendEvent", {
"xdm": {
"eventType": "decisioning.propositionDisplay",
"_experience": {
"decisioning": {
"propositions": renderedPropositions
}
}
}
});
});
});
14
Getting and applying multiple offer-codesgetOffers()Using execute without prefetchadobe.target.getOffers({
request: {
execute: {
mboxes: [
{
index: 0,
name: "mbox1",
parameters: {
a: 1,
b: 2
}
},
{
index: 1,
name: "mbox2",
parameters: {
a: 2,
b: 3
}
}
]
}
}
})
.then(response => {
// get all mboxes from response
const mboxes = response.execute.mboxes;
let count = 1;
mboxes.forEach(el => {
adobe.target.applyOffers({
response: {
execute: {
mboxes: [el]
}
}
});
count += 1;
});
});
15
Read a Target attribute in Experience offer code to dynamically populate experienceread a Customer attributevar a = "${crs.CUSTOMER_ATTRIBUTE_INTEGRATION_NAME.ATTRIBUTE_NAME}"
// CUSTOMER_ATTRIBUTE_INTEGRATION_NAME
// is name of the Customer Attribute integration
//its not alias
16
Adobe page link to Profile and variable glossaryProfile ScriptsAdobe Target Profile Scripts Gloassary
17
Analytics Demystified Link explaining Profile scriptsProfile ScriptsAnalytics Demystified Adobe Target Profiles
18
Read a Customer Attribute in Profile scriptProfile scriptsreturn "" + crs.get('CUSTOMER_ATTRIBUTE_INTEGRATION_NAME.ATTRIBUTE_NAME');
// CUSTOMER_ATTRIBUTE_INTEGRATION_NAME
// is name of the Customer Attribute integration
//its not alias
19
Profile Script code for showing an experience once per sessionProfile Scripts
Inside activity :
adobe.target.trackEvent({
"mbox": "experience-experience_interaction",
"params": {
"experience_id": "your_experience_identifier"
}
});

Profile script :
// Profile script to control session-only display of a banner/activity
// Step 1: Get the existing session ID stored in the profile
var sessionIdBannerShown = user.getLocal('sessionIdBannerShown') || null;

// Step 2: Check if the user is in a new session
if (user.sessionId !== sessionIdBannerShown) {
// Step 3: Check if this call is the result of an interaction with your experience
if (mbox.name == "experience-experience_interaction" && mbox.param("experience_id") == "your_experience_identifier") {
user.setLocal('sessionIdBannerShown', user.sessionId);
// If it's an interaction with your experience, we do NOT show the activity again
return true; // Activity has already been shown in this session, don't show it again
} else {
// Activity not shown yet, and it's a new session, allow the activity to be shown
return false; // Activity can be shown
}
} else {
// Step 4: User is in the same session and the activity has already been shown
return true; // Activity should not be shown again
}
20
Profile script code for checking a param and mbox nameProfile scriptsif (mbox.name == 'target-global-mbox'
&& mbox.param('YOUR_PARAM_NAME') !== undefined
&& mbox.param('YOUR_PARAM_NAME') !== null){
s = mbox.param('YOUR_PARAM_NAME');
}
21
Setting a Profile script code for reading Page-URLProfile scriptsif (page.url != "") {
var url = "" + page.url.toLowerCase();
if (url.indexOf("PARAM1") >-1 &&
url.indexOf("PARAM2") >-1) {
return "true";
}
}
22
Reading a cookie value within Profile scriptProfile scriptsvar cookies = user.header('cookie');
if (cookies.indexOf('YOUR_COOKIE_VAL') >= 0){
return "true";
}
else{
return "false";
}
23
Using Profile script to randomise traffic beyween 2 experiencesProfile scriptsif (!user.get('AB_Test_Groups')) {
var random_number=Math.floor(Math.random()*99);
if(random_number <= 49){
return 'GroupA';
}
else{
return 'GroupB';
}
}
24
Recency in Profile scriptsProfile scripts// this code returns recency in days
// use 3600 * 1000 for hours and 60 * 1000 for minutes
var dayInMillis = 3600 * 24 * 1000;
if (!mbox.param('survey_shown')){
user.setLocal('lastSurveyTime', new Date().getTime());
}
var lastSurveyTime = user.getLocal('lastSurveyTime');
if (lastSurveyTime) {
return ((new Date()).getTime()-lastSurveyTime)/dayInMillis;
}
25
Passing Entity ParameterstargetPageParams()targetPageParams = function() {
return {
"entity.id": "SKU-00001-LARGE",
"entity.categoryId": "clothing,shirts",
"entity.customEntity": "some value",
"cartIds": "SKU-00002,SKU-00003",
"excludedIds": "SKU-00001-SMALL"
};
};
alloy("sendEvent", {
renderDecisions: true,
data: {
__adobe: {
target: {
"entity.id": "123",
"entity.genre": "Drama"
}
}
}
});
26
Frequency capping based on parameter being passed through interact call from another activity.var arenacount=user.get('Arena_ps_based_on_activity_interactcall')||0;
if(mbox.param("web.webPageDetails.targetcustomparameter") == "xyz")
{
arenacount = arenacount+1;
}

return arenacount;
27
Profile script based on page URL for last viewed category pagevar url = page.url;
var category = url.match(/https:\/\/arena-ecommerce-teadgen\.netlify\.app\/#\/category\/(\w+)/);

switch (category ? category[1] : "") {
case "clothing":
return "clothing";
case "shoes":
return "shoes";
case "electronics":
return "electronics";
case "accessories":
return "accessories";
default:
return "unknown";
}
28
Profile script based on parameter passed from developer code.if(mbox.param("web.webPageDetails.Param") == "check")
{
return 'true';
}
29
Delivery APIWith Global Mbox and TNT-IDAPI : https://<your-client-code>.tt.omtrdc.net/rest/v1/delivery?client=<your-client-code>&sessionId=<your-sessionId>

Body :
{
"context":{
"channel":"web"
},
"id": {
"tntId": "005d07c430b740f1b715e93a595be201.37_0"
},
"experienceCloud" : {
"analytics": {
"logging": "client_side"
}
},
"execute": {
"pageLoad" :
{
"parameters": {
"a": 1,
"b": 2
}
}

}

}
30
Delivery APIWith Global Mbox and Profile ParamAPI : https://<your-client-code>.tt.omtrdc.net/rest/v1/delivery?client=<your-client-code>&sessionId=<your-sessionId>

Body :
{
"context":{
"channel":"web"
},
"id": {
"tntId": "005d07c430b740f1b715e93a595be201.37_0"
},
"experienceCloud" : {
"analytics": {
"logging": "client_side"
}
},
"execute": {
"pageLoad" :
{
"parameters": {
"a": 1,
"b": 2
},
"profileParameters" : {
"user_cltv_bucket": "high"
}
}

}

}

31
Delivery APIWith Global Mbox and ThirdPartyId {
"context":{
"channel":"web"
},
"id": {
"thirdPartyId": "test@dwao.in"
},
"experienceCloud" : {
"analytics": {
"logging": "client_side"
}
},
"execute": {
"pageLoad" :
{
"parameters": {
"a": 1,
"b": 2
},
"profileParameters" : {
"user_cltv_bucket": "high"
}
}

}

}
32
Delivery APIWith Custom Mbox and TNT-IDAPI : https://<your-client-code>.tt.omtrdc.net/rest/v1/delivery?client=<your-client-code>&sessionId=<your-sessionId>

Body :
{
"context": {
"channel": "web",
"browser" : {
"host" : "demo"
},
"address" : {
"url" : "http://localhost:3000/"
},
"screen" : {
"width" : 1200,
"height": 1400
}
},
"property" : {
"token": "82ca8c47-3feb-e9f4-dc11-3e07ec61085f"
},
"id": {
"tntId": "005d07c430b740f1b715e93a595be201.37_0"
},
"execute": {
"mboxes" : [
{
"name" : "SummerOffer",
"index" : 1
}
]
}
}
33
Delivery APIWith Custom Mbox and Profile ParamAPI : https://<your-client-code>.tt.omtrdc.net/rest/v1/delivery?client=<your-client-code>&sessionId=<your-sessionId>

Body :
{
"context":{
"channel":"web"
},
"property" : {
"token": "82ca8c47-3feb-e9f4-dc11-3e07ec61085f"
},
"experienceCloud" : {
"analytics": {
"logging": "client_side"
}
},
"execute": {
"mboxes" : [
{
"name" : "SummerOffer",
"index" : 1
}
],
"pageLoad" :
{
"parameters": {
"a": 1,
"b": 2
},
"profileParameters" : {
"newtest": "test1"
}
}

}

}
34
Delivery APIWith Custom Mbox and ThirdPartyIdAPI : https://<your-client-code>.tt.omtrdc.net/rest/v1/delivery?client=<your-client-code>&sessionId=<your-sessionId>

Body :
{
"id": {
"thirdPartyId": "vaibhav@gmail.com"
},
"property" : {
"token": "82ca8c47-3feb-e9f4-dc11-3e07ec61085f"
},
"context": {
"channel": "web",
"browser" : {
"host" : "demo"
},
"address" : {
"url" : "http://localhost:3000/"
},
"screen" : {
"width" : 1200,
"height": 1400
}
},
"execute": {
"mboxes" : [
{
"name" : "SummerOffer",
"index" : 1
}
]
}
}
35
Delivery APIWith Custom Mbox and MarketingCloudVisitorIDAPI : https://<your-client-code>.tt.omtrdc.net/rest/v1/delivery?client=<your-client-code>&sessionId=<your-sessionId>

Body :
{
"id": {
"marketingCloudVisitorId" : "2304820394812039"
},
"property" : {
"token": "82ca8c47-3feb-e9f4-dc11-3e07ec61085f"
},
"context": {
"channel": "web",
"browser" : {
"host" : "demo"
},
"address" : {
"url" : "http://localhost:3000/"
},
"screen" : {
"width" : 1200,
"height": 1400
}
},

"execute": {
"mboxes" : [
{
"name" : "SummerOffer",
"index" : 1
}
]
}
}
36
Delivery APIDelivery API - traceAPI : https://<your-client-code>.tt.omtrdc.net/rest/v1/delivery?client=<your-client-code>&sessionId=<your-sessionId>

Body :
{
"context":{
"channel":"web"
},
"trace": {
"authorizationToken": "4c04a053-ca95-4fb5-a504-6f36b76366ef"
},
"experienceCloud" : {
"analytics": {
"logging": "client_side"
}
},
"execute": {
"pageLoad" :
{
"parameters": {
"a": 1,
"b": 2
},
"profileParameters" : {
"user_cltv_bucket": "high"
}
}

}
}
37
Delivery APIDelivery API - qaModeAPI : https://<your-client-code>.tt.omtrdc.net/rest/v1/delivery?client=<your-client-code>&sessionId=<your-sessionId>

Body :
{
"requestId": "403cbde98bf94019bf87d6ba0c51c3e2",
"context": {
"timeOffsetInMinutes": 330,
"channel": "web",
"address": {
"url": "https://fastidious-jalebi-92178c.netlify.app/?at_preview_token=mXsgwJYuPkalb7O379KWSoZoBsCD5N_inbOgF-5uESo&at_preview_index=1_2&at_preview_listed_activities_only=true&at_preview_evaluate_as_true_audience_ids=4969261",
"referringUrl": ""
},
"crossDomain": "enabled"
},
"id": {
"tntId": "c393a10827d245ecb54f609400562262.41_0",
"marketingCloudVisitorId": "30776182211955070633732753431670007899"
},
"qaMode": {
"token": "mXsgwJYuPkalb7O379KWSoZoBsCD5N_inbOgF-5uESo",
"listedActivitiesOnly": true,
"evaluateAsTrueAudienceIds": [
"4969261"
],
"previewIndexes": [
{
"activityIndex": 1,
"experienceIndex": 2
}
]
},
"execute": {
"pageLoad": {
"parameters": {
"page_name": "Arena Ecommerce"
}
}
},
"prefetch": {
"views": [
{
"parameters": {
"page_name": "Arena Ecommerce"
}
}
]
}
}
38
Passing Entity Parameters for Most Recently Viewed recommendationPass the Parameters on the product page.
targetPageParams = function() {
return {
"entity.id": "SKU-00001-LARGE",
"entity.categoryId": "clothing,shirts",
"entity.customEntity": "some value",
"cartIds": "SKU-00002,SKU-00003",
"excludedIds": "SKU-00001-SMALL"
};
};
alloy("sendEvent", {
renderDecisions: true,
data: {
__adobe: {
target: {
"entity.id": "123",
"entity.genre": "Drama",
"profile.user_cltv_bucket": "high"
}
}
}
});
39
Passing Entity Parameters for Mostly Viewed recommendationPass the Parameters on the product page.
targetPageParams = function() {
return {
"entity.id": "SKU-00001-LARGE",
"entity.categoryId": "clothing,shirts",
"entity.customEntity": "some value",
"cartIds": "SKU-00002,SKU-00003",
"excludedIds": "SKU-00001-SMALL"
};
};
alloy("sendEvent", {
renderDecisions: true,
data: {
__adobe: {
target: {
"entity.id": "123",
"entity.genre": "Drama"
}
}
}
});
40
Passing Entity Parameters for Mostly Sold RecommendationPass the Parameters on the thankyou/checkout page.
targetPageParams = function() {
return {
"entity.id": "SKU-00001-LARGE",
"entity.categoryId": "clothing,shirts",
"entity.customEntity": "some value",
"cartIds": "SKU-00002,SKU-00003",
"excludedIds": "SKU-00001-SMALL"
};
};
alloy("sendEvent", {
renderDecisions: true,
data: {
__adobe: {
target: {
"entity.id": "123",
"entity.genre": "Drama"
}
}
}
});
41
Passing Entity Parameters for Cart Based RecommendationPass the Parameters on the checkout page. Keep the parameter name as cartfunction targetPageParams() {
return {
"cartIds": "352,223,23432,432,553"
}
}
alloy("sendEvent", {
renderDecisions: true,
data: {
__adobe: {
target: {
"cartIds": "352,223,23432,432,553"
}
}
}
});
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100