Tracking the number of times a product is viewed is a great feature for any shopping cart to have. osCommerce has that feature. Having known that and having studied calculus so I thought it may be a good idea to also collect the time series data of the rate of change of a product being viewed. Well, that went on for almost 10 years (didn’t I say time-series data?). One day (life of a business owner first and geek second), so I thought there should be enough data to do some trend analysis and to see if it would be possible to identify a signal to purchase conversion. You know, something is not right when I was doing a sanity check on the aggregated numbers, and they are not tracking my Google Analytic numbers.
osCommerce apparently indiscriminately tracked all “clicks” including robot clicks. Great! Perhaps I will have to figure out a way to reverse bootstrap my data to make something out of it. With all kidding aside, there are really more than one reason that the rate of change of product viewed from visitors may become important, as I can totally see it having a relationship in influencing supply chain management.
So if you care about product viewed and you are in the same school of thought as I on I care not robo-clicks, then go to your products_info.php file and change the line that update the products_viewed column with this:
if (!$spider_flag) tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'");
What this does is that it utilizes the default spider flag to discount a spider (robot) click–please keep that spider file up-to-date. The detail change was also documented in this pull request on my GitHub.
As for now, let’s wait another 10 years, I shall crack that code!