Adobe Target Commands and Profile Scripts Cheatsheet

This page provides quick access to Adobe Target functions/commands/links that are used commonly.
This also covers some Profile Scripts examples that may prove useful for building audiences.
We have also added links to some help-articles and blogs that contain key tips to kickstart your Adobe Target journey.
We hope this will prove helpful to colleagues new to Adobe Target as well as seasoned experts.
Activity | Function/Command | Variation | Syntax at.js | WebSdk Alternate | Syntax WebSdk |
---|---|---|---|---|---|
Adobe Exp Cloud SDK - Taregt APIs | Mobile App Perosonalisation | List of Target APIs for Mobile SDK | |||
Pass params to mbox before a single Adobe Target call | targetPageParams() | 1. Ampersand-delimited list (values must be URL encoded) | function targetPageParams(){ return "param1=value1¶m2=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" } } } }); |
Pass params to mbox before Adobe Target call | targetPageParams() | 2. Array (values do not need to be URL encoded) | targetPageParams = function(){ return ["a=1", "b=2", "c=hello world"]; }; | ||
Pass params to mbox before Adobe Target call | targetPageParams() | 3. JSON (values do not need to be URL encoded) | targetPageParams = function() { return { "a": 1, "b": 2, "profile": { "age": 26, "country": { "city": "San Francisco" } } }; }; | ||
Pass params to all mbox calls on a page | targetPageParamsAll() | Variations same as targetPageParams() | targetPageParams = function() { return { "a": 1, "b": 2, "profile": { "age": 26, "country": { "city": "San Francisco" } } }; }; | ||
Pass params to Adobe Target when an event occurs | trackEvent() | 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 | window.alloy("sendEvent", { "renderDecisions": false, decisionScopes: ["__view__"], "xdm": { "web": { "webPageDetails": { "paramName": "test" } } } }) |
Passing Profile Attributes to the HTML offer | profile attribute | Adobe Target Passing Dynamic Attributes | |||
Read a Target attribute in Experience offer code to dynamically populate experience | profile attribute | var a = “${user.YOUR_PROFILE_ATTRIBUTE}”; | |||
Read a Target attribute in Experience offer code to dynamically populate experience | defining a default value | var a = '${user.YOUR_PROFILE_ATTRIBUTE default="DEFAULT_VALUE"}'; | |||
Getting and applying offer-code | getOffer() 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 } } } }); }); }); | |
Getting and applying multiple offer-codes | getOffers() | Using with prefetch | adobe.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 } } } }); }); }); |
Getting and applying multiple offer-codes | getOffers() | Using execute without prefetch | adobe.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; }); }); | ||
Read a Target attribute in Experience offer code to dynamically populate experience | read a Customer attribute | var a = "${crs.CUSTOMER_ATTRIBUTE_INTEGRATION_NAME.ATTRIBUTE_NAME}" // CUSTOMER_ATTRIBUTE_INTEGRATION_NAME // is name of the Customer Attribute integration //its not alias | |||
Adobe page link to Profile and variable glossary | Profile Scripts | Adobe Target Profile Scripts Gloassary | |||
Analytics Demystified Link explaining Profile scripts | Profile Scripts | Analytics Demystified Adobe Target Profiles | |||
Read a Customer Attribute in Profile script | Profile scripts | return "" + crs.get('CUSTOMER_ATTRIBUTE_INTEGRATION_NAME.ATTRIBUTE_NAME'); // CUSTOMER_ATTRIBUTE_INTEGRATION_NAME // is name of the Customer Attribute integration //its not alias | |||
Profile Script code for showing an experience once per session | Profile 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 } | |||
Profile script code for checking a param and mbox name | Profile scripts | if (mbox.name == 'target-global-mbox' && mbox.param('YOUR_PARAM_NAME') !== undefined && mbox.param('YOUR_PARAM_NAME') !== null){ s = mbox.param('YOUR_PARAM_NAME'); } | |||
Setting a Profile script code for reading Page-URL | Profile scripts | if (page.url != "") { var url = "" + page.url.toLowerCase(); if (url.indexOf("PARAM1") >-1 && url.indexOf("PARAM2") >-1) { return "true"; } } | |||
Reading a cookie value within Profile script | Profile scripts | var cookies = user.header('cookie'); if (cookies.indexOf('YOUR_COOKIE_VAL') >= 0){ return "true"; } else{ return "false"; } | |||
Using Profile script to randomise traffic beyween 2 experiences | Profile scripts | if (!user.get('AB_Test_Groups')) { var random_number=Math.floor(Math.random()*99); if(random_number <= 49){ return 'GroupA'; } else{ return 'GroupB'; } } | |||
Recency in Profile scripts | Profile 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; } | |||
Passing Entity Parameters | targetPageParams() | 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" } } } }); | ||
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; | ||||
Profile script based on page URL for last viewed category page | var 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"; } | ||||
Profile script based on parameter passed from developer code. | if(mbox.param("web.webPageDetails.Param") == "check") { return 'true'; } | ||||
Delivery API | With Global Mbox and TNT-ID | API : https://.tt.omtrdc.net/rest/v1/delivery?client=&sessionId= Body : { "context":{ "channel":"web" }, "id": { "tntId": "005d07c430b740f1b715e93a595be201.37_0" }, "experienceCloud" : { "analytics": { "logging": "client_side" } }, "execute": { "pageLoad" : { "parameters": { "a": 1, "b": 2 } } } } | |||
Delivery API | With Global Mbox and Profile Param | API : https://.tt.omtrdc.net/rest/v1/delivery?client=&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" } } } } | |||
Delivery API | With 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" } } } } | |||
Delivery API | With Custom Mbox and TNT-ID | API : https://.tt.omtrdc.net/rest/v1/delivery?client=&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 } ] } } | |||
Delivery API | With Custom Mbox and Profile Param | API : https://.tt.omtrdc.net/rest/v1/delivery?client=&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" } } } } | |||
Delivery API | With Custom Mbox and ThirdPartyId | API : https://.tt.omtrdc.net/rest/v1/delivery?client=&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 } ] } } | |||
Delivery API | With Custom Mbox and MarketingCloudVisitorID | API : https://.tt.omtrdc.net/rest/v1/delivery?client=&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 } ] } } | |||
Delivery API | Delivery API - trace | API : https://.tt.omtrdc.net/rest/v1/delivery?client=&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" } } } } | |||
Delivery API | Delivery API - qaMode | API : https://.tt.omtrdc.net/rest/v1/delivery?client=&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" } } ] } } | |||
Passing Entity Parameters for Most Recently Viewed recommendation | Pass 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" } } } }); | ||
Passing Entity Parameters for Mostly Viewed recommendation | Pass 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" } } } }); | ||
Passing Entity Parameters for Mostly Sold Recommendation | Pass 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" } } } }); | ||
Passing Entity Parameters for Cart Based Recommendation | Pass the Parameters on the checkout page. Keep the parameter name as cart | function targetPageParams() { return { "cartIds": "352,223,23432,432,553" } } | alloy("sendEvent", { renderDecisions: true, data: { __adobe: { target: { "cartIds": "352,223,23432,432,553" } } } }); |
Tags
What do you think?
What do you think?
This is a great resource
This is incredibly useful! Looking forward to seeing what else is added.