Reputation: 1224
I am using a really simple FAST caching technique. I just implemented this techniuqe and it is great.
I have a row on my database that counts page views. This is also a very simple technique.
$query_rs_update = sprintf("UPDATE table SET views = views+1 WHERE id = %s", GetSQLValueString($colname_DetailRS1, "int"));
I can not find a way to use this technique and COUNT the VIEWS at the same time. Since the Page is being Cached .. ?
Anyone have a better technique? Can you turn a Query to Javascript so it will work using Caching ?
Thanks!
Upvotes: 0
Views: 1025
Reputation: 21
You can use Javascript! Just download Node.js, type the following into your terminal: npm install --save express and npm install --save socket.io. Then, follow this tutorial: https://gist.github.com/Squiva/0eabc2ca5080fd2e4de5
Upvotes: 0
Reputation: 3633
There might be specific reasons to do it way you're doing, but it's generally considered bad practice to track pageviews or activity via MySQL. Your two problems now are that pages are cached, and the tracking ability will be severely underpowered. For example, you'll be missing an ability to separate organic vs robot traffic.
It's best to allow an independent, trusted and capable metrics vendor to do that tracking as they do it for a living - and they can provide a rich dataset to explore.
Note that some hosting companies explicitly forbid forms of 'performance tracking' for managed SQL uses in their terms of service (count increment might apply here, since it can alter index information.) Unless you're using InnoDB storage engine, the performance will always be bad because the table is locked for all reads until the update is finished.
There are limitations to GA, but the positives are that:
Upvotes: 1
Reputation: 60498
You could have some javascript on your page that makes an AJAX request to a separate page that records the page view. This is similar to how most site statistic engines (i.e. Google Analytics) work.
Upvotes: 1