Expand my Community achievements bar.

Applications for the 2024 Adobe Target Community Mentorship Program are open! Click to the right to learn more about participating as either an Aspirant, to professionally level up with a new Certification, or as a Mentor, to share your Adobe Target expertise and inspire through your leadership! Submit your application today.
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!