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

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;