Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hourly Visits Data From Google Analytics API and gapi.class.php

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

like image 216
David Avatar asked Jan 21 '23 15:01

David


1 Answers

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

like image 172
Yahel Avatar answered Apr 01 '23 22:04

Yahel