new plugin: serendipity_plugin_piwik

Creating and modifying plugins.
bernd_d
Regular
Posts: 468
Joined: Thu Jun 03, 2010 9:28 am
Contact:

new plugin: serendipity_plugin_piwik

Post by bernd_d »

I have made a small plugin for piwik. Currently it doesn't do more than showing the most viewed entries of current week in sidebar. (last xx days is currently not possible because of this bug in piwik)

Be warned: I'm not a programmer and my english isn't better ;)

Would be nice if someone of the professional users could take a look at it.

I try to include some more features next time.
Last edited by bernd_d on Wed Jul 10, 2013 1:54 pm, edited 1 time in total.
mattsches
Regular
Posts: 440
Joined: Sat Nov 05, 2005 9:35 pm
Location: Wiesbaden, Germany
Contact:

Re: new plugin: serendipity_plugin_piwik

Post by mattsches »

Hi Bernd,

I installed your plugin on my local machine, and it works just fine :D

Some remarks:
  • Configurable "site_id" would be nice
  • Use PEAR HTTP_Request class for calling Piwik API (and try/catch exception handling)
  • Require PHP5.* and a newer S9y version (not sure which one, though)
Take a look at my proposed changes here and compare it to your file:
serendipity_plugin_piwik.php

Regards
- Mattsches
mattsches
Regular
Posts: 440
Joined: Sat Nov 05, 2005 9:35 pm
Location: Wiesbaden, Germany
Contact:

Re: new plugin: serendipity_plugin_piwik

Post by mattsches »

Looking at the Piwik API docs, there's actually pretty cool stuff in there. Seems like you can even get finished image graphs from Piwik.

On the other hand, a lot of the API methods aren't probably too useful for a blog sidebar. But maybe we can add some cool features in future versions of this plugin?
bernd_d
Regular
Posts: 468
Joined: Thu Jun 03, 2010 9:28 am
Contact:

Re: new plugin: serendipity_plugin_piwik

Post by bernd_d »

Things i want to include:
  • last searched keywords (from search engines)
  • tracking code (only a field for including java script from piwik)
  • number of visitors in the last xx minutes/hours
I also would like to include internal search keywords, but piwik seems not to track this within s9y. Don't know why and how i could fix it, but thats another problem :)

Another thing that would be nice to have is an event-plugin for annotations, which saves entry-title to Piwik, if entry is published :D
bernd_d
Regular
Posts: 468
Joined: Thu Jun 03, 2010 9:28 am
Contact:

Re: new plugin: serendipity_plugin_piwik

Post by bernd_d »

Ok, here is 0.3 if my plugin :)
README.markdown wrote:This is just a small sidebar-plugin which can connect to your Piwik-installation. If you want to use it, you have to set up an user who has at least read-access to piwik. Within user-managment of piwik you can create a new one, if you don't want to use admin.

If you don't need one part of the statistics, just disable it.

If you want to change the order of output, install the plugin twice, it's stackable :) Now, you can can enable or disable any part of every instance until you are happy ;)
ChangeLog

Code: Select all

0.3
   * renaming of language strings
   * included some live-statistics

0.2
   * some changes and optimisations by mattsches, thanks!

0.1
   * first try, a lot of things could behave wrong
Last edited by bernd_d on Sun Nov 03, 2013 7:41 pm, edited 1 time in total.
bernd_d
Regular
Posts: 468
Joined: Thu Jun 03, 2010 9:28 am
Contact:

Re: new plugin: serendipity_plugin_piwik

Post by bernd_d »

Only a small update...

Code: Select all

0.3.1
   * included some debug-logging
   * included "known bugs" into README.markdown
Last edited by bernd_d on Sun Nov 03, 2013 7:41 pm, edited 1 time in total.
Czorneboh
Regular
Posts: 385
Joined: Tue Apr 08, 2008 7:17 pm
Location: Berlin
Contact:

Re: new plugin: serendipity_plugin_piwik

Post by Czorneboh »

Is it possible to use this plugin beside Google Analytics, just for a comparison?
bernd_d
Regular
Posts: 468
Joined: Thu Jun 03, 2010 9:28 am
Contact:

Re: new plugin: serendipity_plugin_piwik

Post by bernd_d »

I don't see any problems if you want to use both plugins. My plugin only gives some output from piwik, it doesn't track your visitors (at the moment, perhaps in future versions).
Jankos
Posts: 1
Joined: Fri Aug 02, 2013 1:10 pm

Re: new plugin: serendipity_plugin_piwik

Post by Jankos »

I compared analytics and piwiki and the result is similar. I greet all
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: new plugin: serendipity_plugin_piwik

Post by Timbalu »

Bernd,
the most n current pages in week do not display the real pages. It links to /archives/n/ which is all entries by date, or (like the last) entries by month, not the current title only, eg.

Code: Select all

    <li><a href="/archives/2013/10/16.html" title="4 views">the title | the blog name</a></li>
    <li><a href="/archives/2013/10/15.html" title="2 views">the title | the blog name</a></li>
    <li><a href="/archives/2013/10/14.html" title="1 views">the title | the blog name</a></li>
    <li><a href="/archives/2013/10/18.html" title="1 views">the title | the blog name</a></li>
    <li><a href="/archives/2013/08.html" title="2 views">the title | the blog name</a></li>
Is that a mistake, or did you want it to display like that? If you can answer this question by first, I am will try to correct this. Is that a limitation by piwik? Maybe then we should push this to additional plugins?!
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
bernd_d
Regular
Posts: 468
Joined: Thu Jun 03, 2010 9:28 am
Contact:

Re: new plugin: serendipity_plugin_piwik

Post by bernd_d »

Hm...i can't reproduce this. As you can see at https://bernd.distler.ws, the articles are linkend and titled as they should.

Titles and URLs are comming from piwik-API and just merged into one array. The output should be the same as in Piwik-dashboard. How does this look like, in your case?
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: new plugin: serendipity_plugin_piwik

Post by Timbalu »

Yes. I see its different on your blog, strange..., but there still is a bug, see

Code: Select all

    <li><a href="http://bernd.distler.ws/archives/251-Excel-Zahlen-in-0,5er-Schritten-runden.html" title="92 Aufrufe">Excel: Zahlen in 0,5er Schritten runden</a></li>
    <li><a href="http://bernd.distler.ws/archives/1329-TrueCrypt-Container-auf-iPhone-oeffnen.html" title="47 Aufrufe">TrueCrypt-Container auf iPhone öffnen</a></li>
    <li><a href="http://bernd.distler.ws/archives/5-AudioConverter-unter-Linux.html" title="16 Aufrufe">AudioConverter unter Linux</a></li>
    <li><a href="http://bernd.distler.ws/archives/16-Doppelseitig-scannen-und-als-PDF-speichern.html" title="11 Aufrufe">Beelitz-Heilstätten</a></li>
    <li><a href="http://bernd.distler.ws/archives/335-Beelitz-Heilstaetten.html" title="11 Aufrufe">Doppelseitig scannen und als PDF speichern</a></li>
The last two are displaced.

Beside that, why could that be that I do not get the real titles..? This is an old blog with a very new piwik counter, maybe these are links come in by search engines based on the calender day/month links...
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
bernd_d
Regular
Posts: 468
Joined: Thu Jun 03, 2010 9:28 am
Contact:

Re: new plugin: serendipity_plugin_piwik

Post by bernd_d »

Timbalu wrote:Yes. I see its different on your blog, strange..., but there still is a bug, see
...
The last two are displaced.
Oh, you are right. Seems, there is different name-sorting for urls and pages-titles if they have same view-count :( I didn't notice this until now.
Timbalu wrote:Beside that, why could that be that I do not get the real titles..? This is an old blog with a very new piwik counter, maybe these are links come in by search engines based on the calender day/month links...
Main problem is, that Piwik-API only delivers page-titles OR page-urls. You never get both values in one array :( Within the plugin i try to make two different fetches from api and merge them into one array.

In your case it could be, that the api-arrays completely differ from my one.

Best solution would be to get page-url from piwik at grab page-titles from s9y-database, but i don't know how this could be done easily.
onli
Regular
Posts: 2825
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: new plugin: serendipity_plugin_piwik

Post by onli »

What data do you have, and which do you want? Maybe I can help.
bernd_d
Regular
Posts: 468
Joined: Thu Jun 03, 2010 9:28 am
Contact:

Re: new plugin: serendipity_plugin_piwik

Post by bernd_d »

In my case, i get URLs like /archives/67-D-Link-DNS-323-im-Test.html from piwik and for output i would need page-title from database. Could be possible with article-id i hope, but it would be needed for different kind of url-rewriting.

But this only would solve my problem, i don't know why Timbalu gets different links/output. This need to be checked within piwik-dashboard and compared to output of the api.
Post Reply