Keeping stats synced in external application

Dear All,

First of all I would like to Thanks PIWIK team for creating such a beautiful analytics software. We are using it for last two year without any problems.

We have an application with hundered of pages being tracked by PIWIK with separate site in PIWIK for every page.

We show the stats (views, visitors and conversions etc) along with the pages listing in our application.

Currently, we fetch a stats for pages from their creation date and update in database to show them to user, which takes a lot resources and time.

Now, I am considering to track when I last updated the stats and then fetch the differential stats only next time and add them up to last fetched stats.

Is there any machenism available in PIWIK to keep the stats synced in our application, or any other better approach to accomplish this?

Thanks for your help.

Imran

If you purely use the Piwik APIs from: http://piwik.org/docs/analytics-api/reference/

Then the result should be returned fast (assuming you setup cron as per How to Set up Auto-Archiving of Your Reports - Analytics Platform - Matomo )

If you are doing your own processing then I recommend using a cache class such as Zend_Cache or else

stats = visits, unique visitors, and conversions

matt, Yes, I am using Piwik APIs (VisitsSummary.getVisits etc).

If I setup the cron properly, is it okay to fetch the stats for every page from the date of it’s creation everytime? Currently, when I fetch stats for multiple sites, in the date range I consider the creation date of oldest page (from the list of current sites) to determine the last{N} days.

An important point to note is that I need the total stats for every site from its creation date. These stats are not for charts etc, but to show the totals for every site.

Another thing, to fetch the stats I need to make three API calls (views, unique visitors, and conversions) to Piwik. Is there any possiblity that I send only one request and get all the stats in the response? We have PHP guys if this requires additional coding. Is there any related plugin or pointers we can get started with it.

I really appreciate your help. Hats off.

Sorry it’s a bit complicated and am not sure I understand. can you put here the HTTP requests you use to PIwik API?

matt, here are the HTTP requests to Piwik API for visits, unique visistors and conversion goals:

http://our-standalone-piwik-server/index.php?module=API&method=VisitsSummary.getVisits&idSite=1,2,3,4,5&period=range&date=lastN&format=xml&token_auth=abc123

http://our-standalone-piwik-server/index.php?module=API&method=VisitsSummary.getUniqueVisitors&idSite=1,2,3,4,5&period=range&date=lastN&format=xml&token_auth=abc123

http://our-standalone-piwik-server/index.php?module=API&method=Goals.getConversions&idSite=1,2,3,4,5&period=range&date=lastN&format=xml&token_auth=abc123

To have faster response time you can increase the “Browser archiving” in Settings > General settings

or you can use period=previousX instead of period=lastX as it will not include today and be faster