Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Analytics API "ga:day" dimension and more than 1 month of data returns aggregate instead of absolute values

I am attempting to retrieve Google Analytics daily visitor counts. I'm following this blog post.

For under 30 days of consecutive data, everything works great. The problem is that the result rows get "grouped together." Consider this query:

    { ids: 'ga:44339606',
  'start-date': '2013-01-01',
  'end-date': '2013-02-14',
  dimensions: 'ga:day',
  metrics: 'ga:visits',
  segment: 'gaid::-1' }

The values returned for days 01 -14 are incorrect, because they actually represent the sum of January 1st + February 1st, and the sum of January 2nd and February 2nd, and so on. In other words: there is only one entry returned for each day of the month, 1-30, instead of returning 44 entries.

How can I adjust for this, without breaking the query into multiple calls?

like image 624
Zane Claes Avatar asked Feb 14 '13 01:02

Zane Claes


1 Answers

Turns out, I wanted the ga:date dimension instead of ga:day Check out the playground; it's great for figuring out params: https://ga-dev-tools.appspot.com/explorer/

like image 123
Zane Claes Avatar answered Nov 01 '22 06:11

Zane Claes