> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackone.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect Google Analytics with Service Account – StackOne Hub

> Link a Google Analytics account in the StackOne Hub using Service Account. End-user guide to authorize the integration and start using Google Analytics actions.

> [!WARNING]
>
> You need permission to create service accounts, grant roles and create keys in the Google Cloud project, such as the Service Account Admin, Service Account Key Admin and Project IAM Admin roles. You also need the Administrator role on the Google Analytics account or property to add the service account as a user.

## Creating a service account key

The service account is created in a Google Cloud project, then added as a user in Google Analytics. Analytics access is granted in Google Analytics, not in Google Cloud IAM.

**1. Enable the required APIs**

Sign in to the [Google Cloud Console](https://console.cloud.google.com/) and select the project. Turn on the Google Analytics Admin API and Google Analytics Data API.

<ul>
  <li>For each API, search for it in **Search (/) for resources, docs, products, and more** and open it.</li>
  <li>Click **Enable**.</li>
  <li>If the page shows **Manage** and **API Enabled**, the API is already on.</li>
</ul>

**2. Create the service account**

Open **IAM & Admin** > **Service Accounts**.

<ul>
  <li>Click **Create service account**.</li>
  <li>**Service account name**: `StackOne Integration`</li>
  <li>Click **Create and continue**.</li>
</ul>

![Create service account form with the Service account name field and the Create and continue button highlighted.](https://mintcdn.com/stackone-60/pMIP-vOSCXF_XTCE/connectors/googleanalytics/images/service-account-config-create-account.png?fit=max\&auto=format\&n=pMIP-vOSCXF_XTCE\&q=85\&s=87e5b4caf65b80b742ec323359111792)

**3. Create the JSON key**

In **Service Accounts**, click the email of the new service account and open the **Keys** tab.

<ul>
  <li>Click **Add key**.</li>
  <li>Select **Create new key**.</li>
  <li>**Key type**: **JSON**</li>
  <li>Click **Create**. The key file downloads once, and Google can't recover it if it is lost.</li>
  <li>If your organization blocks key creation with an organization policy, ask an organization policy administrator to allow it for this project.</li>
</ul>

![Create private key dialog with the JSON key type and the Create button highlighted.](https://mintcdn.com/stackone-60/pMIP-vOSCXF_XTCE/connectors/googleanalytics/images/service-account-config-create-key.png?fit=max\&auto=format\&n=pMIP-vOSCXF_XTCE\&q=85\&s=167da5d9c0b321c580b289e9095cad13)

## Granting the service account access in Google Analytics

The service account reaches nothing until it is added as a user in Google Analytics. Grant it on each account or property this connection should reach.

<ul>
  <li>Open [Google Analytics](https://analytics.google.com/) and click **Admin**.</li>
  <li>To grant a whole account, under **Account** click **Account access management**. To grant a single property, under **Property** click **Property access management**.</li>
  <li>Click **+** in the top right, then click **Add users**.</li>
  <li>Enter the service account's email address, which ends in `iam.gserviceaccount.com` and is the `client_email` value in the key file.</li>
  <li>Clear **Notify new users by email**. A service account has no inbox.</li>
  <li>**Direct roles and data restrictions**: select **Viewer** for read-only access, **Editor** to let the connector change property configuration, or **Administrator** to also reach account-level settings such as data sharing.</li>
  <li>Leave the data restriction options unticked. Ticking No Cost Metrics or No Revenue Metrics removes those metrics from report responses.</li>
  <li>Click **Add**.</li>
  <li>The Google Analytics Demo Account cannot be used. Nobody holds the Administrator role on it, so the + Add users control is hidden and a service account cannot be added. Use an account your organization owns, or create one.</li>
</ul>

## Entering the key

Open the downloaded `.json` key file in a text editor. The whole file, including the outer braces, is the key.

<ul>
  <li>Copy the **Service Account Key (JSON)** across.</li>
  <li>Actions take the Google Analytics account or property as an input rather than a connection setting, and only the ones the service account was added to are returned.</li>
</ul>

## Link the Account

**1. Connect**

<ul>
  <li>Click **Connect**.</li>
  <li>If applicable, the provider will redirect you to a sign-in or authorization page. Complete the provider's authorization flow.</li>
  <li>Once authorization is successful, you will see a confirmation popup.</li>
</ul>

**2. Use Actions**

Connect an AI platform to the linked account's actions. See [AI Platforms](https://docs.stackone.com/ai-platforms/overview.md).

Other ways to call actions are listed in [Protocols & SDKs](https://docs.stackone.com/connect/protocols-and-sdks.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.