Google Lets You Automate Analytics Using Apps Scripting

Many people have been asking for a simple way to put Google Analytics data into a Google Spreadsheet. Once the data is inside a Google Spreadsheet, users can easily manipulate Google Analytics data, create new visualizations, and build internal dashboards.
So today Google has launched a new integration that dramatically reduces the work required to put Google Analytics data into any Apps Script supported product, such as Google Docs, Sites, or Spreadsheets.
Here’s an example of Google Analytics data accessed through Apps Script and displayed in a Google Spreadsheet.

Custom API Dashboards – No Code Required

A popular use case of this integration will be to create dashboards that automatically update. To make this easy to do, Google has added a script to the Spreadsheets script gallery that handles all this work – no code required. The script is called Google Analytics Report Automation (Magic).

This script is a great template for starting your own project, and Google states that it had many internal Google teams save hours of time using this tool. Here’s a video demoing how to build a dashboard using this script:
You can find this script by opening or creating a Google Spreadsheet, clicking Tools -> Script Gallery and searching for “analytics magic”.

Writing Your Own Script

Of course many developers will want to write their own code. With the new Analytics – Apps Script integration, you can request the total visitors, visits, and pageviews over time and put this data into a spreadsheet with just the following code:

// Get Data.
var results = Analytics.Data.Ga.get(
    {‘dimensions’: ‘ga:date’});

// Output to spreadsheet.
var sheet = SpreadsheetApp.getActiveSpreadsheet().insertSheet();
sheet.getRange(2, 1, results.getRows().length, headerNames.length)

// Make Sandwich.


To get started now, read Google’s Automated Access to Google Analytics Data in Google Spreadsheets tutorial. Also check out the Google Analytics Apps Script reference docs.


Solving Business Problems

Are you ready to start building solutions using Google Analytics and Google Apps Script?
To encourage you to try out this integration, Google is giving out Google Analytics developer t-shirts to the first 15 developers to build a solution using both APIs.

To be eligible, you must publish your solution to either the Chrome Web Store or the Spreadsheets Script Gallery and include a description of a business problem the script solves. Google will then collect these scripts and highlight the solutions in an upcoming blog post. After you publish your script, fill out this form to share what you’ve built.

Leave us your comments..

Samir Saleem

An innovative and dynamic marketing expert having worked for both local and multinational organisations,having expertise in leading diverse assignments on devising digital/social media marketing strategies, promotions, public relations and business development. As an experienced social media strategist and business analyst, he manages several brands via his 2nd Startup Hybrid Signals ( Samir is an award winning technology and social media blogger and can be reached at

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *