yretuta
yretuta

Reputation: 8111

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

  1. update a database counter everytime a page is visited
  2. check if a the product is repeatedly viewed in the same terminal to avoid multiple viewing from one user

How will I go about implementing this?

Upvotes: 0

Views: 156

Answers (1)

Jani Hartikainen
Jani Hartikainen

Reputation: 43263

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.

Upvotes: 3

Related Questions