Expand my Community achievements bar.

Join us for an upcoming in-person Adobe Target Skill Builders event ~~> We're hosting these live learning opportunities to equip you with the knowledge and skills to leverage Target successfully. Learn more to see if we'll be coming to a city near you!
SOLVED

Page counter profile script with reset

Avatar

Level 2

Hello,

 

I'm looking to try and create a profile script that counts the number of times that a page has been visited by a visitor, and outputs that number. I also want to specify that once that number reaches a particular value X the counter resets to 1. Does anyone know how I can do this?

 

Thanks very much!

 

1 Accepted Solution

Avatar

Correct answer by
Level 2

Where the profile script is named "pageViews":

 

var count = user.get('pageViews') || 0;
count++;

if(count > 50) {

  count = 1;

}

return count; 

View solution in original post

2 Replies

Avatar

Correct answer by
Level 2

Where the profile script is named "pageViews":

 

var count = user.get('pageViews') || 0;
count++;

if(count > 50) {

  count = 1;

}

return count; 

Avatar

Level 2
Thanks so much - this was exactly what I was after!