I have this fiddle where when the user clicks a button the counter works: http://jsfiddle.net/z66WF/
This is the code:
Here you have a working simple exemple, wich write the counter in a simple txt file (no sql db needed)
Download btn