The functions for importing Google Analytics data to a spreadsheet are now also available for Google Docs! With this solution, you can create automatically updating Analytics reports in a GD spreadsheet – these can contain analyses and visualizations that are not available through the GA user interface. You can combine data from several GA profiles, and merge it with data from other systems, such as internal sales data. And having the reports in Google Docs makes it easy to share them within your company or with clients.
Try it now here! (If you get a “We’re sorry, your spreadsheet cannot be copied at this time” error, open your Google Docs file list, click Create new-> From template -> Public templates, and search for “Google Analytics Functions Examples”)
You can use the functions following the instructions here (they are for Excel but usage is practically the same) and the parameter reference here. There’s also a nice tutorial made by someone else here.
The Google Docs functions also work on a Mac, as well as any other systems from which Google Docs can be accessed – you can even check the latest stats with your mobile.
There are three ways to get started using the functions in Google Docs:
- Do it yourself: Copy the function code from here and paste it to a Google Docs spreadsheet file (open the Script editor from the Tools: Scripts menu, paste the code there, and save).
- A customized solution: Put an email to us at email@example.com describing the kind of report you’d like to see in Google Docs, and I’ll give you price for creating it.
Using the functions in a Google Docs spreadsheet is almost identical to how they are used in Excel: there are the same three functions (getGAauthenticationToken, getGAaccountData and getGAdata), and they take the same parameters as the Excel versions (with a few minor exceptions, which are explained below). The function code is of course different (I’ve converted it from VBA to Google Apps Script), but for the end user this doesn’t make a difference.
Having the GA functions available in Google Docs opens up some nice possibilities. See for example this chart I created using the functions in Google Docs – it’s embedded here to always show the distribution of visits during the last 30 days.
Also in other ways, the GD version is less stable than the Excel one – every now and then the authentication doesn’t work, or fetching data gives the “servers busy” error. These are caused by problems in Google’s end, so unfortunately there isn’t anything we can do currently to fix them – but Google Docs is developing rapidly so I’m sure the stability will improve.
The other difference is that the GD version doesn’t yet support fetching conversion goals with the getGAaccountData function – I just didn’t have the time to implement that yet.
If you get an error complaining about “rate limit exceeded”, this is due to too many functions being updated simultaneosly (the GA API only allows 10 queries per second). You can avoid this by staggering the queries so that they are not all fired at the same second; to do this, go to Tools: Scripts: Script editor, and in the gatGAdata function, above the line which has the UrlFetchApp, insert these two rows:
var randnumber = Math.random()*5000;
With this in place, the queries will wait for a random time of between zero and five seconds before being updated, thus it’s less likely that you would hit Google’s limitation of 10 queries per second. If you still have trouble, you can duplicate the second row, this will cause a wait of between zero and ten seconds (and of course, you can put this line there as many times as needed, if you’re still hitting the limit).
In case you have any questions regarding the usage of this solution, please visit our help forum.