Jump to content

Page View Counter for Daily Views


Recommended Posts

Hi Guys, I have seen some other threads that talk about this but nothing recent nor in line with what I need. 


I have basically created a page in which I am tracking the number of views. I update the counter which is tied to a field I added to the page's template that I am tracking. The field is hidden from the website admin and only used for this data. 


However, now I need to track it on a daily basis. I am thinking of keeping track of all time view total for 30 days and perhaps saving that and allowing the user to see the page views of last 7 days, each day as a number and then 30 days of data. This way if I want to build in reporting functionality I can. 


What I need help with adding a date to the page_views field but also, knowing how many page_views for today, yesterday, day before etc. 

Here is what I have so far and its working. Now I need to associate a date with every day. NOT every update of the page_views field. 

if (!$user->hasRole('superuser')) {
		    $page->page_views += 1;
			echo $page->page_views;

Any guidance, help, suggestions is absolutely appreciated. 


Link to comment
Share on other sites

Howdy @quickjeff,

I'm using two fields, one for the visitor's ip and another for the timestamp. The visitor's ip allows for unique visits, and also for telling you who is visiting your site often.

On another note, google analytics gives you this same information, and much more.

  • Like 1
Link to comment
Share on other sites

1 hour ago, Zeka said:


This is awesome and I starting building off of this but now, I can only overwrite todays date. If I am tracking lets say 30 days, I think it would require 30 fields unless I create some kind of repeater field but in my mind, that doesn't sound like the right way. ? 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...