How can I keep track of what users do on my web page?
I mean stuff like this: if I have a page displaying products that my company sells I want to know what products the user has viewed; or if I have a dating site I want to display for each user the last 5 users that viewed his profile, the number of times his profile has been viewed since it was created and so on.
In the first case I want to know only what products have been viewed by each user in his last session. But in the second case it makes more sense to know the information since his profile was created.
Could I use a field in the database like a counter? In the first case it would be initialised to 0 each time the session starts etc...
Please give some tips to begin my research from.