how to count click tab menu and insert to database

I have a tab menu with the following structure, clicking on which will add an active class to the li element
Now I need to count the number of clicks of each tab separately and more importantly save (insert) it in the database
Please help with an example how can I implement it?

BR