Analytics
4K members online now
Understand information in your reports and troubleshoot reporting issues such as self-referrals, (not set) data, and inaccurate information
 
Guide Me
star_border
Reply

Google Analytics Core API

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

 

 

Hello is there a way to compare data using "Compare to previous period" using the Google analytics core api?

 

Thanks,

2 Expert replyverified_user
Marked as Best Answer.
Solution
Accepted by topic author Anthony E
January 2017

Google Analytics Core API

Top Contributor
# 2
Top Contributor

Hi @Anthony E you would need to start using Reporting API v4 - please follow up with this for more information https://developers.google.com/analytics/devguides/reporting/core/v4/basics#multiple_date_ranges

 

Hope it helps!

 

Kind regards,

Zorin

Web analyst @ escapestudio.net

Google Analytics Core API

Rising Star
# 3
Rising Star

Are you already using the api? If you're just getting started then try experimenting with the Google Analytics add on which is available for Google Sheets - it's awesome!

John Wedderburn, Advertiser Community, Rising Star
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.

Google Analytics Core API

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

Hi John,

 

So far i've been using the google analytics add-on. But i guess there are no ways of comparing dates using this add-on. right?

 

 

Google Analytics Core API

Top Contributor
# 5
Top Contributor

Hi @Anthony E with the sheets addon you could do it with 2 separate queries. You could also try using the supermetrics addon for sheets which if I remember correctly allow that.

 

Kind regards,

Zorin

Web analyst @ escapestudio.net

Google Analytics Core API

Rising Star
# 6
Rising Star

You can have a large number of queries - the limitation is the the number of cells in your spreadsheet and/or the number of daily calls to the API. It's pretty hard to exceed this. You can create two or more queries which enable you to compare date ranges. See here for example: https://docs.google.com/spreadsheets/d/1k4rANR7OQ_gs9qcZHz3RoOkz76HyDGU7Ke10R9xew7I/edit?usp=sharing

 

You can get quite creative with the functions in Google Sheets regarding formula and dates. For example, in this simple example I have used the today() function (though you don't have to, of course) to give a rolling data comparison based on today's date.

 

 

John Wedderburn, Advertiser Community, Rising Star
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.

Google Analytics Core API

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭

Hi Zorin,

 

Thank you for your response. Actually my report is set to update every morning and fetch data for the last 30 days. What i want is to compare this data with the previous period automatically. 

So i should find a way to ask GA to fetch data from Last 30 days and the 30 days before that.

Cheers,

Google Analytics Core API

Rising Star
# 8
Rising Star

Is that not what the spreadsheet I shared is doing? If not, you can always change the start and end date ranges to give you the date you need. I've added an extra tab called data example to show this. You can schedule the report using the GA add on so it updates daily.

John Wedderburn, Advertiser Community, Rising Star
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.

Google Analytics Core API

Visitor ✭ ✭ ✭
# 9
Visitor ✭ ✭ ✭

What i see in your report is that you're getting data for a specific period.

 

Is there a way i can set the Start date 30days before today?

Google Analytics Core API

Rising Star
# 10
Rising Star

Set start date to =today()-30, as I have in the spreadsheet. If you look in the tab named date range 1 you can see that the data is collected from the 12:e december 2016 to 11:e jan 2017. If you do not wish to include today's data then you can adjust with end date =today()-1

 

John Wedderburn, Advertiser Community, Rising Star
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.