Some time ago I was looking something like this, really. And how can I count clicks on a button with HTML/JS, is it OK?:
<button><a href="https://counting.world/api/set/value?name=My counter&secret=MYSECRET&value=1">PRESS ME</a></button>
<button><a href="https://counting.world/api/set/value?name=My counter&secret=MYSECRET&value=1">PRESS ME</a></button>
As a side note this would also trigger a navigation away from your site not something you probably want. You should be doing this behind the scenes with JS.
You could look into https://countapi.xyz/. You won't get the displaying part but there's an API for your use case.