SQL Query or piwik code to display ad hoc stats


Can you please provide guidance for an SQL query or point to existing piwik code which can be used to display (in number and/or in graph) ad hoc stats?

I am mainly interested on unique visitors and pageviews per minute and per second over selected short time periods.

An ad hoc stats page like the above would be a great addition to Piwik! (Admins will be using it at their own discretion to avoid overloading their servers.) Yet, even if you can provide directions for a suitable SQL query, that would do the job, for the time being.

Thanks in advance,

We recommend against using SQL if possible, and instead use the very powerful Analytics APIs: Piwik Analytics API - Analytics Platform - Matomo

Also see: Real Time Analytics - Analytics Platform - Matomo

Thank you for this info.

I took a look; I guess I would use VisitTime or VisitsSummary Modules, but, does the “period” parameter accept minutes and seconds? (I remind you that we would want analysis at this level for partcular short periods.) According to the documentation, it does not.

For example, is the following a legitimate expression:

&period=range&date='2013-11-22 22:00:00','2013-11-22 22:01:00'


If not, what are our alternatives?

Please clarify!


Piwik only works by full day… if you need sub-day precision then using the database is the best solution!