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
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Page counter profile script with reset

Rhodri2
Level 2
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
emarks87
Correct answer by
Level 2
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
emarks87
Correct answer by
Level 2
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

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