Google Analytics
How do I import Google Analytics data to Google Sheets?#
Google Analytics is a web analytics service offered by Google that tracks and reports website traffic, currently as a platform inside the Google Marketing Platform brand. In this guide, I'll walk you through how to import data from Google Analytics into Google Sheets.
BEFORE YOU BEGIN
If you haven't already, install the Data Connector Add-on for Google Sheets from the Google Workspace Marketplace
Step 1: Create your API Request
- Open Google Sheets and click
Add-ons -> Data Connector -> Manage Connections - Click
NEW COMMAND - Name your command. In this case, we will name it
analytics - Select
APIfor the Type - Select and connect to the
Google Analytics ReportingOAuth2 provider - Select
POSTfor the Method - Enter
https://analyticsreporting.googleapis.com/v4/reports:batchGetin the URL field. - Enter a header with Key of
Content-Typeand Value ofapplication/json - Enter the following for the Body (your
viewIdcan be found at http://analytics.google.com/): - Select
JMESPathfor the Filter type - Enter
reports[].data.totals[].values[]in the expression box. - Click
SAVE
Step 2: Run the command
- Now, you can run your command:
=run("analytics","pageviews,2021-05-07,2021-05-07")