Using Profile Script token values in Activities A/B test custom code



Hi, for Profile Scripts you can use JavaScript arrays and objects as the values and it works fine within the Profile Script. However accessing the value in an Activity A/B test via Custom Code Modifications the values aren't deserialized the same.

Profile Script (user.testValue)

return ['test', 'blue'];


return {key1: 1, key2: 2};

Within an Activity A/B test modification custom code

var profileValue = "${user.testValue}";


The console output will be


Basically for string arrays, the quotes are removed when accessing the value within an Activity and the JS object is returned in a different format. Is there a method of accessing the token values other than ${user.token} that would retrieve the value correctly?

I only found this storing an array of strings in a profile attribute  thread with the same issue, but the answer didn't actually address the question.


Accepted Solutions (0)

Answers (5)

Answers (5)



An example use case would be storing the last view pages. In the Profile Script, I can just add page.path into an array and then use that array in the Activity.

Profile Script (user.testValue)

var testValue = user.get('testValue') ||[];


return testValue.slice(0, 10);

in Activity custom code

var lastPageViews = ${user.testValue}; 


In this example I can easy store the last 10 pages the user viewed and get access to it in an A/B test. This is just an example and I know I can achieve it in other ways, but having the ability to easily store data as a string array or as a JavaScript object greatly simplifies things.

Is this a bug or a limitation in Target?




I am having this very same issues here as well. Is there any official response to this? Looks like storing data through profile scripts and retrieving it from the offers are focused on just chains of alpha-numerical characters.

How we are supposed to build a rich profile across multiple websites with just this option? The only array that seems to exist in here is the Category Affinities which btw, as far as I know, there can just exist one instance per profile.



I need the quotes so I can just use the value as a string array like below.

var profileValue = ${user.testValue}; 


to get

I could set the value as ["'test'", "'blue'"] but then I would have to manage the extra quotes within the Profile Script. Also, that doesn't work.