Page counter profile script with reset | Community
Skip to main content
Level 2
July 2, 2021
Solved

Page counter profile script with reset

  • July 2, 2021
  • 1 reply
  • 1349 views

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!

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by emarks87

Where the profile script is named "pageViews":

 

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

if(count > 50) {

  count = 1;

}

return count; 

1 reply

emarks87Accepted solution
Level 2
July 6, 2021

Where the profile script is named "pageViews":

 

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

if(count > 50) {

  count = 1;

}

return count; 

Rhodri2Author
Level 2
July 7, 2021
Thanks so much - this was exactly what I was after!