If you’ve ever felt the need to reduce the time spent on web analytics, cutting out a big portion of the manual data-gathering monkey work, you’re definitely looking for a new way to automate your reporting efforts. For those who use Google Analytics, there are powerful tools which allow you to query the Analytics APIs and to build automatic reports in Excel with a one-time initial setup. (Supermetrics Data Grabber is probably the best-known tool of this kind.)
Are you scared of Office licenses, but love Google Drive sharing options? Then you’ll be glad to know there is a free add-on for Google Sheets that can do all the dirty work for you, leaving you only the creative burden of organizing data in personal dashboards or whatever you need.
This tool helped me a lot in automating and improving my SEO reporting activities during the last few months.
I'm going to explain here in few steps how to install it and use its basic functions in order to save some precious working time.
Installation
- Log into Google Drive with the account you use for Google Analytics.
- Head to this page and click on the “Free” button. (You’ll be redirected to Google Sheets.)
- Allow the usual permissions and the add-on will be installed.
Create your first report
Let’s start getting some data. Clicking on “Create new report,” you’ll open the simple interface of the add-on.
The form is very easy and self-explanatory. Simply name your report, choose your Analytics profile, and set the metrics and dimensions you want to monitor. Don’t worry if it seems limited; in the next step, you’ll be able to customize everything you need (e.g., date ranges and filters). In this basic example, just choose Sessions in the “Metrics” field.
Click on “Create report” and the following table will show up:
(In a while, we’ll see how to use and improve it, since it’s the core of the Google Sheets Analytics add-on.) For now, simply click “Run reports” in the “Add-ons” label: The tool will query the Analytics APIs to get the data you asked for, and a pop-up will tell you if the request was successful. In a new sheet, you’ll see the actual report, which in this case shows the number of sessions registered within the default date range (the last 7 days).
Want to create a new report while maintaining the other one for comparison purposes? Simply add a new column by copying and pasting the old one, then modifying the values where needed. (The reports will be generated in two separate sheets). This is much faster than clicking on “Create new report” and using the GUI every time!
Improve your report
Time to go back to the “Report Configuration” sheet. As you saw before, there are many more fields than the ones included in the GUI. Every field, of course, can be edited or filled manually.
Some of them might need an explanation of the required syntax. Let’s take a look at what I mean.
View (profile) IDs
Here, you can specify the Analytics view you want to query. That “IDs” is quite misleading: You can choose only one view here. If you need to explore two or more views, then you’ll need to add new columns. To find your view ID, just use the GUI of the add-on; or go to Analytics and click on “Administration," followed by “View settings.”
Syntax — ga:12345678
Start and end dates
You can either write dates manually (it’s OK if you need to collect data within a specific time range) or use relative dates with formulas like today and yesterday. Let’s say you want to create a “last-week-vs.-this-week” report. As suggested in this nice Google’s walkthrough, an elegant way to automate calculations is to create two columns (i.e., reports) named, for example, “this week” and “last week” with the formulas set like this:
More examples of creative uses of relative dates can be found here. For reference, you can also check Google’s official documentation.
Syntax — mm/dd/yyyy or relative dates
Last N days
Leave it blank if you use the Start Date and End Date fields.
Metrics and dimensions
Here you can tell the add-on which data you want to grab from Google Analytics. You can set out up to 10 metrics and 7 dimensions for each report, separated by commas. If you need help with finding valid combinations between metrics and dimensions, head to this page.
Syntax — ga:sessions, ga:users... and ga:country, ga:bounces...
Sort
This field allows you to change how the tables of your report are organized. You can choose:
- how to group data (by priority);
- which order (ascending or descending) to use.
An example will make this clearer. Suppose you wrote ga:sessions in the “Metrics” field and ga:pagePath, ga:country in the “Dimensions” field: the report will show you, for each page, the list of countries which generated at least one session, ordered alphabetically.
Now suppose you want to group this information by country (in other words you want to know, for each country, the list of pages which generated at least one session): you simply need to write ga:country in the “Sort” field.
Finally, let’s say you want to improve this table, showing for each country, sessions in descending order. Simply add -ga:sessions and the minus sign will do the magic.
Syntax — ga:country, -ga:sessions...
Filters
Let’s continue with the same example and say you want to restrict data visualization to a specific country (e.g. Italy). This is what the “Filters” field is used for: fill it with the instruction ga:country==Italy and that’s it. As you see, I used the operator == to query the Analytics API with the right syntax. In order to learn which operators you can use to filter metrics and dimensions properly, see this list. Of course you can also combine filters with the OR and AND operators, represented respectively as a comma (,) and a semi-colon (;).
Syntax — ga:country==Italy; ga:medium==organic...
Segment
The add-on allows you even to apply segments to your report. You can either recall segments already defined in Google Analytics or create a new dynamic segment on the fly. I’m not familiar with dynamic segments – never tried them honestly – so I’ll just point out this guide for those who want to take a deeper look into this topic. To use an existing segment you have to know its ID: the easiest way to find it is through Google’s APIs Explorer, which will give you every detail about the segments set in your Analytics profiles.
Syntax — gaid::abc123
Sampling Level
If you have to deal with a large amount of data (more than 500k sessions within the chosen time range) your Analytics reports will likely be sampled. Using this field is like adjusting the sampling slider in the usual Google Analytics panel: leave it blank if the sample size satisfies your needs, write FASTER (slider to the left) for a faster query with a smaller sample, HIGHER_PRECISION (slider to the right) for a slower query with a larger sample. If you want more details, here is Google’s official document about how sampling works.
Start index and max results
As Google reports, “The Analytics Core Reporting API returns a maximum of 10,000 rows per request.” The default value for the field “Max Results,” however, is 1,000: This means that, if you want to retrieve more data (i.e. rows), you’ll need to specify the desired number here. Let’s say then the total results of your query exceed 10,000, and you want to see also the rows that go beyond that limit: The field “Start Index” comes in handy since it allows you to choose the row (i.e., index) from which to start displaying the data.
A real-life example
What I want to share with you now is a concrete use case of the Analytics add-on. Some time ago I decided to improve one of my monthly SEO reports creating a self-updating dashboard in Google Sheets. I had to figure out how to collect automatically the following KPIs:
- organic sessions by month and by device category;
- organic leads by month and by device category;
- organic sessions Vs. all sessions by month.
A brief clarification before exploring the dashboard: I used fixed dates here in order to spot the monthly trend of my business and to store historical data, but of course you might find more value in using relative dates according to your own purposes. It’s up to you.
Let’s take a look at the report configuration sheet.
The first three queries have been set up as follows.
- Start Date and End Date (01/01/2015 and 12/31/2015): What I need here is the whole year. I’ll select month later as a dimension to be able to analyze the monthly trend, and I’ll create a brand new report when the new year starts (simply copy-pasting the old one and changing the dates). This way I can always refer to the past reports to discover year-over-year trends. Doesn’t matter if the current year is not over yet: future months will get zero results and update themselves when it’s time. Be careful: Selecting such a wide time range might result in sampling problems. To reduce or avoid them you could split your query by 12 – one per month – then aggregate numbers in another sheet.
- Metrics and Dimensions (ga:sessions, ga:goal1Completions, ga:goal2Completions and ga:month): The specified dimensions tell Google I want to split the required metrics of my reports by month. In order to use the metric goalXXCompletions you obviously have to replace XX with your goal’s ID (you can easily find it in Google Analytics).
- Filters (ga:medium==organic;ga:deviceCategory==desktop/mobile/tablet): This way, the queries will get only organic results in response, split by device. Why not simply building one query with deviceCategory set as a dimension? Because – you’ll see – formulas in the dashboard would be more complex, since I’d have to recall data from other sheets with some sort of lookup based on two criteria (month and device).
The fourth query is very basic as it just asks Analytics for the overall sessions by month.
For reference, here is a screenshot of the first report, which shows the volume of the desktop organic traffic by month and the related goal completions.
Setting up the SEO dashboard
Now that the data is present, let’s jump to the fun part: building a nice dashboard which gives an immediate overview of the KPIs I want to highlight. At this point it’s only a matter of functions and calculations. Let’s open a new sheet.
Organic sessions
(Click on the image for a better view.)
The “Total” row and the deltas below are the result of very simple calculations based on the rows above. What is worth looking at is cell B5. The formula is spread over the table in the “Desktop,” “Mobile” and “Tablet” rows.
Here it is:
=VLOOKUP(B$2, OrganicDesktop!$A$16:$D$27, 2, FALSE)
The VLOOKUP scans the specified range of the "OrganicDesktop" sheet looking for the value of the cell B2 (the number of the month, in this case, 1) and returning the corresponding value in the second column of the table (the number of sessions).
Why reference the value to search for with a cell and not directly with the number? It’s a well-known trick which here allows me to drag the formula applying it to every cell of the row, thanks to the “dynamic” reference to the row 2 (where I wrote the numbers of the months).
The rows “Mobile” and “Tablet” are populated in the same way, replacing the referenced sheet respectively with "OrganicMobile" and "OrganicTablet".
The pie chart on the right just displays the total average organic sessions by device. To find the percent value of the desktop traffic, for example, I applied this very simple formula:
=SUM($B5:$M5)/SUM($B$8:$M$8)
Organic leads
The second part of the dashboard is basically a copy of the first one. The only difference is that the cells of the rows “Desktop," “Mobile” and “Tablet” sum up two VLOOKUPs, since I have to report here the total number of leads (goal 1 completions + goal 2 completions).
This is the formula of the cell B33:
=VLOOKUP(B$2, OrganicDesktop!$A$16:$D$27, 3, FALSE)+VLOOKUP(B$2, OrganicDesktop!$A$16:$D$27, 4, FALSE)
Organic sessions vs. all sessions
Finally, a very simple one. The row “Free traffic” uses values from the row “Total” of the “Organic sessions” table, while the row “All traffic” searches for values in the “All” sheet through a VLOOKUP formula:
=VLOOKUP(B$2, All!$A$16:$B$27, 2, FALSE)
Conclusion
This dashboard is really a basic example of what you can do with the help of the Google Analytics add-on for Google Sheets. Once you understand how to retrieve data properly from the Analytics APIs, you are free to organize them as you like in a new sheet (or in a new file, with the IMPORTRANGE function), in order to set up a totally automatic and self-updating panel according to your needs.
One last thing: Remember, you can also schedule reports to update them automatically without pushing a single button.
Head to Add-ons > Google Analytics in the menu above to find what you need.
Do you use a similar process? I'd really enjoy seeing your thoughts below in the comments.
Simply amazing, I use Google Analytics almost everyday and I didn't know about this feature to implement personals reports with Google SpreadSheet. I have tried and is very powerful. Thanks for sharing it.
It is powerful indeed, and totally free. Glad you found it useful!
It seems very powerful, I'm going to try for sure. The ability to schedule the reports can save a lot of time.
Thanks for mentioning our Supermetrics Data Grabber for Excel! Just wanted to let you know we also have a Google Sheets add-on that does Google Analytics better than the official add-on (for instance, it can avoid Google's data sampling), and also includes many other sources like Moz, AdWords, Bing, Facebook, Google Search Console & SEMrush.
Thanks for the tip Mikael. It seems a very powerful tool, I'm definitely going to try it. Could be the topic of a future post :)
That would be great! Let me know if there's anything I can help you with when you're trying out the tool.
Love this post! I really hope more people will start sharing their use cases with using GA and Google Sheets together. We've been using this tactic for years even before Google created it's own add-on to support this. Although it's not super scalable (we usually see issues when above 25 reports in the same Google Sheet) it makes it very powerful for fast analysis and visualisation.
That's true Martijn, I have dashboards with more than 30 reports and I get errors sometimes. Anyway I usually re-run the queries and everything goes fine. For reference, here you can find the limits and quotas of the Core Reporting API.
One neat trick is to match your traffic against updates, I built something a while back using sheets - bit.ly/svpenda but haven't maintained it.
Another neat trick you can embed graphs into Google Sites to create dashboards that non-digital marketings can use without any issue. Critically for international marketers you can blend multiple sites into one page which is something you can't do in GA natively.
This is a great post, I just wish you could pull out other sources into GA as easily! (such as GSC
Thank you Gerry.
Your spreadsheet with the algo updates timeline can be very useful, let me know if you are going to update it.
And yes, I'd like to be able to grab Search Console data and other stuff as easily too!
:-( no plans to update it at the moment, but I do often plot against client activity such as migrations and other elements!
I am using Google Spreadsheets since I saw some really good presentations at the SMX about this possibility. It helps so much in your work and saves so much time that I can´t even imagine working without it anymore after I´ve started it.
I will set up the SEO dashboard, haven´t used it in that way yet, thanks for sharing this.
Hope it is going to help you :)
Anyway, my dashboard is really a small example. Once you automate the data grabbing you can build really complex panels to aggregate/manipulate them and track your KPIs the way you want, then just sit down and see data come in.
Hello Gabriele,
Very user-friendly tool for making all your analytics report automated. I personally use this tool to generated Google analytics report for all my clients and it reduces 90% of my efforts and provide very accurate data. I personally recommend everyone to use this tool to make your reporting process faster.
Actualy I don't know much more about analytics, infact it take a lot of time and analysis to deeply know about it. Sure this tool is going to help me further. Nice post indeed.
nice article. Should be useful with sharing Analytics data. Currently I just use screen shots taken with OneNote.
Gabriele, thanks for a great post. Was definitely helpful and gave me a few ideas.
Do you know of a way to create a trended report using this add-on? As it stands this is more useful for a snapshot.
Ideally, I'd like to schedule the report to pull sessions for a specific segment each week and add that data to the next column/row in a different sheet. As it stands, I can automate weekly snapshots, but it'll just overwrite the data. Worst comes to worse, I'll just have to do one copy/paste :)
Hi Lee, it gets more tricky here but nothing impossible, I do it for some of my reports. I'll try to simplify the whole thing and let you figure out the details:
That's it. When you have to add 10 more weeks, simply create a new file where you run the new queries and import data in your main file. I suggest that you separate files only to prevent APIs errors caused by too many requests.
The process can't be totally automatic, but of course, if you create the main template in the right way and set up formulas properly, you avoid a huge part of manual work.
This is the best thing ever... One question - is there any way to make the reports re-label the column headings? I have 6 goals I'm tracking and it's hard to remember what goal4 is compared to goal5, etc... If I try to add notes in the sheets, they are wiped out every time the report is regenerated.
Hi Jannette, I don't think there's an automatic way to do it, but you can easily add a new sheet with your custom column headings, and then just copy the data from the original report under them, referring to the cells range you need. This way, your new sheet will be up to date when you'll refresh the report. I think it's a good compromise.
Very useful article! We have tried and it works great!
Amazing!.. Thanks for the information - Seriously!.. This will go a long way. I had no idea.
This tool is going to change how I use Google Analytics. It took a while to figure out some of the syntax for generating specific reporting, but for anyone who blogs heavily, this add-on is a must-have in my opinion.
Thanks for sharing, I use to do some reports for customers copying data from spreadsheet, but the option you explain is much better
Very nicely Explained!! I am a regular user of Google analytic and sometimes i use Google Sheets too, but never know about this feature. you make it very simple and thanks for all the syntax and links too.. This is very useful to personally me. I will start using this feature, Thanks again :-)
Thanks Peter, hope it will save you some time!
Awesome! You have no idea how much time this is going to save me. Thanks
As per the details given here it seems this would be so useful. I will try this today. Thank a lot Gabriele Toninelli
Very technical & incredible useful information. This shows the power of Google Analytics :)
sometimes, when I want to look my site on google analytics, I access to my account and look it