Search API Connector Documentation

Print

Import Google Analytics (GA4) Data to Google Sheets

premium

In this guide, we’ll walk through how to pull Google Analytics GA4 data directly into Google Sheets, using the API Connector add-on for Sheets.

Contents

Before You Begin

Click here to install the API Connector add-on from the Google Marketplace.

Part 1: Connect to Google Analytics

If you haven’t connected API Connector to Google Analytics before, you’ll first need to initiate the connection as follows. Once you’re authenticated, you can connect to any of GA’s reporting APIs.

  1. Open up Google Sheets and click Extensions > API Connector > Manage Connections.
  2. In the list of available connections, find “Google Analytics” and click Connect.
    google-analytics-img1
  3. You will be directed to google.com and asked to allow API Connector to view your Google Analytics data.
    google-analytics-img2
  4. You’ll then be returned to your Google Sheet, and can verify that your Google Analytics connection is active.

Part 2: Sample Google Analytics Data API (GA4) Request

GA4 is the newest version of GA. Confusingly, it is not accessed through the Google Analytics v4 API, though it certainly sounds like it should be… instead, GA4 is accessed through the Google Analytics Data API. Here’s a complete sample request to demonstrate how it works.

  • Method: POST
  • Request URL: https://analyticsdata.googleapis.com/v1beta/properties/250094890:runReport
  • OAuth: Google Analytics
  • Headers: Key = Content-Type, Value = application/json
  • Request Body: { "dateRanges": [{ "startDate": "2021-05-01", "endDate": "2021-05-31"}], "dimensions": [{ "name": "country" }], "metrics": [{ "name": "activeUsers" }] }
  • JMESPath: rows[].{dimensionValues:dimensionValues,metricValues:metricValues}
  • For the Request URL, substitute in your own property ID where it says 250094890.
  • For the Request body, check Google’s API documentation for examples and a list of available metrics.

The whole thing should look like this:

google-analytics-img10

Part 3: API Documentation

Official GA4 API documentation: https://developers.google.com/analytics/devguides/reporting/data/v1/basics

Previous Import Google Ads Keyword Planner Data to Google Sheets
Next Import Google Analytics (UA) Data to Google Sheets

Leave a Comment

Table of Contents