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
API
for the Type - Select and connect to the
Google Analytics Reporting
OAuth2 provider - Select
POST
for the Method - Enter
https://analyticsreporting.googleapis.com/v4/reports:batchGet
in the URL field. - Enter a header with Key of
Content-Type
and Value ofapplication/json
- Enter the following for the Body (your
viewId
can be found at http://analytics.google.com/): - Select
JMESPath
for 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")