Thanks for replying! Good to hear that this idea is not just the product of my crazy brain! Here is my situation and what I would like to achieve:
I have got:
- a Drupal site for which statistics need to be gathered and displayed in nice charts to users (Piwik module is integrated)
- a Piwik installation on the same server (but eventually could be on another)
- site tracking stats, basically the default Piwik tracking statistics
- user data stats (e.g. how many registered users there are on the site in total, how that number has evolved over days/months, etc.)
This question is about this second type of stats.
I’d like to generate these reports via Piwik - the data is already collected in my site’s database and I only need daily granularity tops, so I figured that it is kind of pointless to collect this extra info via tracking script on each page hit. I checked out the Example plugins and found I could easily create a report by directly querying an external (i.e. my site’s) database.
So far so good - but the report that I get is not stored. Every time I request the report on my site’s interface, it calls to Piwik for the report generation, Piwik has to connect to my site’s database, get and analyse the data, and then send back the report (long story short: performance overhead!). I would like to take this a step further and not just generate the report in Piwik, but also store it in the Piwik database.
So let’s say that I want to keep track of the total number of registered users on my site - the scenario I would like to achieve goes like this:
- I let the site take care of the user data as usual
- once a day cron triggers a custom Piwik plugin that connects to the site’s database and runs a query to find out how many registered users there are today (basically “select count(*) from users” )
- Piwik stores this info in its archive just as it does for the default tracking reports
- when the report is requested, Piwik can just query its own archive and hand me the report
It would be great if I could carry all my statistics data and analysis outside my site - so Piwik runs in its own quiet space, keeps all the report data, and assumes all of the stats-related performance load. Plus I love the fact that Piwik can store archived reports, so no space is wasted. Well, all in all Piwik looks like just the solution I need to keep all my stats data under control. What I can’t figure out is how to put this external report data into the Piwik archive. As far as I’ve got, the archiving methods seem to deal only with the data first stored in the raw log tables, and I’m not sure if I need that step (and indeed whether that would work out at all).
If you could nudge me in the right direction here, that would be great!
And if I have left out something else you’d like to know (in spite of the wild verbosity), please do ask!