I work with Google Analitycs API. I want to get all sessions for last 7 days per day like this in only one API call:
[day 1] -> 10
[day 2] -> 100 ...
I use this:
$service->data_ga->get('ga:'.$profile['id'],'7daysAgo','today','ga:sessions');
It works fine but return the sum. I've checked with https://ga-dev-tools.appspot.com/query-explorer/ and for me needed i should add metrics ga:date so the date to be individualy per day not all.
I've tried to add metrics at the end of line:
$service->data_ga->get('ga:'.$profile['id'],'7daysAgo','today','ga:sessions','ga:date');
I got this error:
Uncaught exception 'Google_Exception' with message '(get) missing required param: 'start-date'' in
The answer is this:
$SecondaryParams = array('dimensions' => 'ga:date');
$results = $service->data_ga->get('ga:'.$profile['id'],
'7daysAgo',
'today',
'ga:sessions',
$SecondaryParams);
Send dimensions as array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With