Hi all, I am writing a PHP script that I want to be able to get Visitor count information from a self hosted version of Matomo, is such a thing possible?
For this all I want to know is quantity, not sure I’m going to care about many details at this point.
I’ve checked out the API and can’t find a getVisitors call, is there such a thing?
I believe it would. A couple of follow up questions:
Would it be better to use a key instead of being anonymous?
If I wanted to get the results for a week, would I need to submit the request for 7 times? or is there a way to ask it for a week’s worth of information in one request broken up by date?
Being anonymous means your Matomo is accessible anonymously, I suggest you don’t do that for security purposes (and the use of a key is not a problem, as the API would be used through your PHP, then the key would not be publicly visible).
period — the period you request the statistics for. Can be any of: day , week , month , year or range . All reports are returned for the dates based on the website’s time zone.
day returns data for a given day.
week returns data for the week that contains the specified ‘date’
month returns data for the month that contains the specified ‘date’
year returns data for the year that contains the specified ‘date’
range returns data for the specified ‘date’ range.For example to request a report for the range Jan 1st to Feb 15th you would write &period=range&date=2011-01-01,2011-02-15
In this case you’ll get the cumulated nb_uniq_visitors / nb_users / … for the selected period.
If you need the detail for each day:
"Date format must be: YYYY-MM-DD, or 'today' or 'yesterday' or any keyword supported by the strtotime function (see http://php.net/strtotime for more information): today, yesterday"
Not sure what the issue is, or how to fix it. I’ve also tried adding a space between today and yesterday no change.
OK, I wonder if there is also a limit to how many days you can do at one time… /?module=API&method=VisitsSummary.get&idSite=4&period=day&date=2022-08-25,2022-08-24,2022-08-23,2022-08-22,2022-08-21,2022-08-20,2022-08-19,2022-08-18 also has the same error.