Stats plugin / Hit counter

Continuing the discussion from Very little visitor stats:

With the new widgets I started to build something very simple, similar to what @thguenther had mocked up further down that thread. The result is here: https://github.com/FabianSperrle/kirby-stats

I’m not completely happy with the result so I would love your feedback! What is okay, what would you have done differently? I’m somehow in a “kirby fever” in the last days trying to learn some new things about it so I would really appreciate your comments.

One problem I ran into is the router: I somehow couldn’t get optional URL-parameters to work, so I have this ugly second route now. Apart from the fact that it obviously doesn’t work on multilang sites at the moment and the widget is not responsive it should do its (very basic) job.

7 Likes

What about calling the stats folder _stats (with an underscore) instead? Then one could use a page called stats.

I didn’t tried it yet but looks super interesting! Thanks.

I just tried it, but unfortunately it causes Kirby to crash.

Apparently it’s related to this, since I do not have a multi-language setup.
Is it necessary to have this added to the config.php?

c::set('language.detect', true);
c::set('languages', array(
			'code'    => 'de-de',
			'name'    => 'Deutschland',
			'locale'  => 'de_DE',
			'url'     => '/de',
			'default' => true,
		)
	));

I changed 'url' => '/de', to 'url' => '/', that’ll do it for now.
nevertheless, panel keeps crashing. Not sure what causes this.

May be it’s because I am on 2.0.7?

Looks very interesting, though. Nice work! :slight_smile:

Would it be possible to have logged in users with admin role not tracked?

/edit: the page ‘stats’ is not being created.

I hope not, but I was developing on a multi-language setup… It’s still very rough, but I’ll be working on it an keep you guys posted.

Actually I’m on 2.0.7 too :wink:

Ignoring admins crossed my mind already, too. I think it should be no problem.

Here’s what I got in the error log:

PHP Warning:  Illegal string offset 'name' in ... htdocs/kirby/branches/multilang/language.php on line 14

Appears it’s a multi language problem.
It might take a while, but I will be digging into this, too. :wink:

Just a quick test on a multi language site, first I got an error which disappeared after I created a folder called stats, but now all I get is an empty widget (well, not quite, it shows the headline …) Looks like it’s missing a JS script, console tells me it can’t find variable chart …

Edit: after adding Chart.min.js to assets that error disappeared, but still no chart showing up

Are you using Chrome? There’s a bug in the chart library…

And for all the rest of the stuff missing/not happening: It might have been good to push what I did… :frowning:

no, I tested with Safari und Firefox … I suppose I messed something up, in fact, it doesn’t write anything to file.

Maybe it was a bit early too ask for opinions… This is clearly not developed far enough. I guess I’ll go get some different installations with single and multi language to test everything properly…

let me know if I can be of any help on that single language testing. :smile:

Data collection should be fine now for single language pages, feel free to check it out again :smile: https://github.com/FabianSperrle/kirby-stats/releases/tag/v.0.2.1

In Chrome it might still happen that the chart is not displayed…

works like a charm! :smiley:

Just the thing I was missing: anonymous stats without having a third party software to be installed. :+1:

Thanks! :smile:

/edit:
unfortunately I ran into an error when not having browsed to panel first, will post on github.

that’s what happens when I think I have to create new features late at night… Fixed.

1 Like

shouldn’t you be sleeping, then? :wink:

Fixed! Thanks! :smiley:

I just filed an error I get when not logged in to the panel.

A suggestion: Currently, every page refresh is counted towards the stats. Maybe it would be a good idea to set a cookie for every page, I know that’s not foolproof either to get unique impressions, but maybe a bit more so ?

Were you using the 0.2.1 release? this should already be fixed on the master branch…

Definitely already better than now. How long would you set that cookie for then?

I am on 0.3.0 and I have to write a few more words to get this posted;)

I just published 0.3.1… :wink:

1 Like

As regards the cookie, maybe a persistent one that lives until the user deletes it or just a session cookie, the last looks better in the stats;)

And the error is gone :smile:

1 Like