Welcome Guest, Not a member yet? Register   Sign In
page view tracking... any suggestions ??
#1

[eluser]egoslip[/eluser]
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
#2

[eluser]TheFuzzy0ne[/eluser]
Have you looked into Google Analytics, or a similar service?
#3

[eluser]egoslip[/eluser]
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
#4

[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...
#5

[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.
#6

[eluser]egoslip[/eluser]
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.

IE

today|yesterday|last7|last30|all_time|date

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.
#7

[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...




Theme © iAndrew 2016 - Forum software by © MyBB