implemenatations of product hit counters
I have been scouring for a while about this one but haven't seen a decent tutorial.
the problem is I want to create a hit counter everytime a product's page is viewed
I am using a PHP MVC framework and these are what I want to do
- update a database counter everytime a page is visited
- check if a the product is repeatedly viewed in the same terminal to a开发者_运维问答void multiple viewing from one user
How will I go about implementing this?
Depending on how accurate you want it to be...
- If accuracy is not a major concern, save a cookie or a session value to the client. Check this before incrementing counter. This is simplest to implement.
- Create a table in your db which keeps track of what IP address (or other metric) has viewed what product. This would give a more accurate reading I think, but is considerably more complex.
精彩评论