Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

iterating over an array while creating profile scripts


Level 1

I am trying to code a profile script that looks for some query parameters.  At some point after I have split the query parameters into an array, how should i iterate over the array to find the query parameter I need.  I have tried using for, forEach, while loops...all show some syntax error although the function works perfectly fine when ran on the browser console.

5 Replies


Community Advisor

Hi @sonalipai 

As you said it's working fine in bowser console however not in profile script, Is it possible you to put your code here in dummy form so we can troubleshoot 


Level 1

Hello @Gokul_Agiwal :

Found the solution, apparently iterators do not work in profile scripts that is because adobe targets does not like javascripts with more than 2000 js instructions in the script.  The easiest way was to use a split() function.

Example like 

var text = "How are you doing today?";
varcount = text.split("are").length -1;


Employee Advisor

Looks like you found a solution. There is a pretty decent built in method also just to share:

var param = page.param('PARAMETERNAME');

If you know the name of the page query parameter you can reference it directly in a profile script like above. 

The little "available tokens" widget on the right side of the edit script pane shows some of these.


Hope that is helpful.


Level 1


That was my initial solution.  But unfortunately, there is no good documentation around page.param.

How should page.param be used if there are multiple same name params in the query string.  I was assuming that page.param would return an array, but i think it returns a string.