Google Analytics Reporting API Compare Date with Previous Period

997 views
Skip to first unread message

Ann Zhong

unread,
Aug 28, 2015, 1:24:39 AM8/28/15
to Google Analytics Reporting API
Hi All, 
Just wondering is there a way using Google Analytics API to extract data from certain period and compare it with the previous period like the following?


I know some third party jQuery did this nicely, but is it possible to do this only via Google Chart API and Google Analytics API?

Thanks in advance.




Matt

unread,
Aug 28, 2015, 11:12:17 AM8/28/15
to Google Analytics Reporting API
The Core Reporting API accepts a single start date and end date in the request, and as such is completely customizable for the time periods you are requesting. But this means you will need to make at least two requests  to compare two time periods. You will need implement the logic yourself to determine what determines the time period. This open source Google Analytics Embed API demo shows how you can do such a comparison.
-Matt

Ann Zhong

unread,
Aug 29, 2015, 8:21:41 PM8/29/15
to Google Analytics Reporting API
Hi Matt,
Thanks a lot for your reply :)
I have looked at the example you give to me but the example shows comparing data in different charts. However, is it possible to comparing data in the same chart? It seems that I could do this by making two requests and writing the script by myself. I am currently using gapi.analytics.report.Data instead of gapi.analytics.googleCharts.DataChart so it should give me more flexibility to control how I wish the final chart could be displayed. Would it possible that you give me an example in doing this? I am not quite a developer but I am keen to learn google analytics API by myself since I find how powerful it is.

Many thanks.

Kind regards,
Ann
Reply all
Reply to author
Forward
0 new messages