Like the others mentioned, use a counter and an automation to increase whenever the event occurs. I have an example you can follow here - mine is for adding “points” when a chore is complete, but you should be able to follow it for your use case: https://smarthomepursuits.com/chore-tracking-with-point-system-in-home-assistant/