Re: How to track link clicks in my database?
Plus if you don't want to run the hits query every time the page loads, you could cache the query say weekly, or update regularly some sort of results summary in another table from which you read the output to the webpage.
Having another table to which the hit query results are written will allow you to get clever later on if you feel like it by running different summaries and would allow you to get time-related information about your clicks, not just the totals. ie. you''ll have a set of results, each with a date, so you can record how they change over time.
If you can't do scheduling on the server, you could put a 'last updated' date into the summary table and test the date vs. today's date on a popular web page. When the date difference hits your chosen recording period, run any hits queries you like and record them with today's date.
Its a bit more advanced and perhaps something for later (especially date comparison) but I thought worth mentioning because after 6 months of doing what you are planning to do, we suddenly realised it would have been useful to record progress over time as well as accumulating and showing the totals each time the webpages loaded.
We now have a complex file which runs regularly on demand from a main website page, depending on the date and records all sorts of stuff from the various product tables into another separate results table.
|