If this is data you want as the developer:
The only reliable way I would know is to use a mysql database and collect the data for you to manipulate.
There is a high-score tutorial that gives a good introduction to how to store data in a database. (AJAX, MYSQL, PHP)
If it's just for the user, you could just store a variable in local storage.
construct.net/en/tutorials/tracking-users-ajax-php-mysql-1061