• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
page view tracking... any suggestions ??

alright so lets say I have 1,000 pages and I would like to track how many page views via set intervals like pv-today | pv-yesterday | pv-last7 | pv-last30 | pv-alltime. whats that best way to go about inserting and retrieving the view data from the database without having it cause a complete melt down of the db..

my original idea was to have a table for just views where it would count the total number of views for that day IE - id|page_id|views|date - then just use the db sums function to get the counts but then I would be having 1k rows every day one row for every page every day.....

I would love if someone else might have another idea on how to accomplish this with out over bloating the db

Have you looked into Google Analytics, or a similar service?

ya i use google analytic.

this is something I want to be part of my script... it is really action taken on the site i just used page views as an easy example

[eluser]Iván Argulo[/eluser]
I think the best way to do this is using a little slice of JavaScript, calling the URL in your app, which stores the data in the DB, or use a hook, in the post_controller event...

[eluser]Johan André[/eluser]
Does'nt Google Analytics have an API?
You should be able to pull data with that into your site.
If so, let GA handle the statistics. I guess (without knowing your coding skills) it's pretty solid.

I think I figured it out

Have a cron job check the db every day and shift the view columns over so one view row per page.



so the date column only get updated every 30 days from last update. then every day it would move the today views to the yesterday column then every multiple of 7 get moved over to the last 30 and every 30 days it updates the all_time.

Let me know if my logic sounds reasonable or I'm just going out of my mind.

[eluser]Iván Argulo[/eluser]
It could work...

I'd store the date (day, month and year), and the total of views for each page. Then, when querying the data, just have to add a where statement, filtering or grouping by month, day, week...

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.