I'm trying to get daily visits from my instance of piwik for every day in the week.
Currently this query is ret开发者_如何学Curning the sum of all my visits for the entire week. Is there any way to separate this out into days?
http://piwikexample.com/?module=API&method=VisitsSummary.getVisits&idSite=1&period=range&date=2011-08-18,2011-08-25&format=json&token_auth=#########
Actually figured it out. What I was missing is:
lastX for the last X periods including today (eg &date=last10&period=day would return an entry for each of the last 10 days including today). This is relative to the website timezone.
From http://piwik.org/docs/analytics-api/reference/#API
Piwik's documentation isn't the best
I had to use the old-fashioned trial-and-error approach.
There are 3 ways, if you have period
set right:
- lastX
- This returns the last X days, including current day.
- i.e.
&period=day&date=last10
- previousX
- This returns the previous X days, excluding today.
- i.e.
&period=day&date=previous10
- date range
&period=day&date=2011-08-18,2011-08-25
Just make sure you use period=day
instead of period=range
and you'll be good to go. See this note from the API:
Note: if you set 'period=range' to request data for a custom date range, the API will return the sum of data for the specified date range.
Reference: Reporting API (date) section
精彩评论