Page Hit Counter Concrete 5.7

Permalink
Im looking for a Page Hit Counter Block that can be added to a sitewide footer and give views per page and may per site and per month type statistics. I noticed there was one for 5.6 that does a similar job.http://www.concrete5.org/marketplace/addons/stats/...

Is this fairly easy to achieve or can someone produce a block for this.

View Replies:
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi dkw15,

If you are looking for detailed statistics, I would recommend setting up a Google Analytics account.
https://www.google.com/analytics/...

This block looks fairly complex and would require a substantial investment in time to recreate for 5.7.
dkw15 replied on at Permalink Reply
Hi mrkdilkington

My site is internal so I don't know whether Google analytics would be suitable. So there's no simple way to count every visit to a page (doesn't have to be unique really just a simple page counter)
MrKDilkington replied on at Permalink Reply
MrKDilkington
@dkw15

I need a basic page counter for some projects I am working on. I've been given some advice on how to make something light that should do the job. When it is done I will put it in the marketplace.

Are your internal users logged in?
dkw15 replied on at Permalink Reply
Some are some are just guests. I have user accounts enabled. But ideally, it would just recognise anyone has been on the page and just increment by one. Doesn't particularly matter if they have revisited or are logged or not. Just need it to increment quite simply.
MrKDilkington replied on at Permalink Reply
MrKDilkington
@dkw15

That is the goal of what I am making, something to purely record page information and views, then update a table by one.

The rest would be excluding admins and logged in users, but that should be configurable.
dkw15 replied on at Permalink Reply
That sounds like the kind of thing. That's something you're developing now? Count me in to try it out!!
campbell replied on at Permalink Reply
campbell
I'd be interested in this feature, as well, if it's still something being considered for development.
afnfun replied on at Permalink Reply
I also needs hit counter for concrete5 5.7
did manage to find a solution?
theana27 replied on at Permalink Reply
theana27
Here the very simple page counter for a page type. It count all visitors exept admins.
Just create number attribute "page_count". Sign it to page type you'd like to count. Include this code somewhere in a page template.
<?php 
$c = Page::getCurrentPage(); 
$cp = new Permissions($c);
               $c = Page::getCurrentPage(); 
               $page_count=$c->getAttribute('page_count');
                if (!$cp->canAdminPage()) { 
                     $c->setAttribute('page_count', $page_count+1); 
                } ?>
            <div><?php if ($cp->canAdminPage()) { echo 'This page was viewed '.$page_count.' time(s).'; } ?></div>

If you want sort block PageList by most viewed pages you have to extend PageList's controller or make single page with custom page list.
switch ($orderBy) {                               
                    case 'chrono_asc':
                         $this->pl->sortByPublicDate();
                         break;
                    case 'most_popular':
                         $this->pl->sortBy('ak_page_count', 'desc');
                         break;
                    default:
                         $this->pl->sortByPublicDateDescending();
                         break;
                 }
Steevb replied on at Permalink Reply 1 Attachment
Steevb
Thanks for that.

Modified your code and made a FREE package for the marketplace.

Also works with v8, see attached.
Steevb replied on at Permalink Reply 1 Attachment
Steevb
I have produced a really basic hit counter that counts EVERY page hit. It does not give individual page hits.

You're welcome to use it, however there is no support. See attached.
tallacman replied on at Permalink Reply
tallacman
There is also a page stats package in the PRB that should be available soon. It is pretty cool.