Question

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

Was it helpful?

Solution

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: enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top