I am using the gapi class 开发者_运维技巧to access analytics data. It works great and i have daily visits to my site. What I would like is to be able to get hourly visits over a date range, say from 11th Jan to 12th Jan (2 days) which would return me 48 data points, one for each hour in teh range. I'm sure this is simple but I cannot find how to do it anywhere. Presumably there is some setting in the metrics parameter of the requestReportData() method that allows this???
Any help gratefully received, thanks...
David
To do this, you'd need to set two dimensions
Dimensions: ga:hour, ga:date
Metric: ga:visits
You can test out this query on the Google Analytics API Query Explorer.
Untested, this should look like this with gapi.class.php:
$ga->requestReportData($profile_id,array('hour','date'),array('visits'), null, null, '2011-01-11', '2011-01-12', 1, 48);
You'll get data back that looks like this:
精彩评论