Search code examples
phprestanalyticsweb-analyticsmatomo

Piwik Analytics get summary statistics for particular page via REST


Trying to implement Piwik using REST API over http but need a little help.

What I'm trying to do is get the analytics for a particular page where a custom field = x.

I'm not sure if I'm going about it the right way but I have this so far:

http://www.mysite.co.uk/dashboard/analytics/index.php?module=API&method=VisitsSummary.get&idSite=1&period=month&date=today&segment=customVariableValue1==x&filter_limit=20&format=xml&token_auth=xxxxxxxxxxxxxxxxx

My custom field is set up and viewable in the admin.

However the result just seems to return 0 for everything. I'm testing by inserting the url directly into a browser and also by fetching in php.

Also is there a method to get all statistics for a particular page and given date range where custom field = x? I can't seem to see one in the API docs.

Any help/ examples would be appreciated.


Solution

  • In case anyone else happens to be looking for this I ended up using the getPageUrl method:

    $url = "http://www.mysite.co.uk/piwik/index.php?module=API&method=Actions.getPageUrl&pageUrl=/foo.php?id=" . $id . "&idSite=1&period=month&date=today&format=php&filter_limit=1&token_auth=xxxx";
    

    regards,

    fl3x7