# How do I connect Insightor to Google Analytics?

> Create an OAuth client in your Google Cloud project, add the redirect URI, sign in from Insightor and pick your GA4 property to see statistics in WordPress.

Source: https://docs.phluit.com/products/wordpress-plugins/connect-insightor-to-google-analytics/

Insightor can show your Google Analytics statistics inside WordPress. To read them, it needs read-only access to your Google Analytics, through an OAuth client in **your own** Google Cloud project. This takes about ten minutes, once.

You only need this for statistics in WordPress. Tracking visits works with the measurement ID alone. See [Getting started with Insightor (Google Analytics)](/products/wordpress-plugins/getting-started-insightor/).

## Step 1: Open the Google account tab

In WP Admin, go to **Insightor → Settings → Google account**. Keep this page open: it shows the steps and your site's **redirect URI**, which you need in step 5. It's your site's address followed by `/wp-admin/admin-post.php`, for example `https://example.com/wp-admin/admin-post.php`.

## Step 2: Create or pick a Google Cloud project

Sign in to the Google Cloud Console (console.cloud.google.com) with your Google account and create a project, or pick one you already have. Google Cloud is free for this.

## Step 3: Enable the two Analytics APIs

In the project, go to **APIs & Services → Library** and enable:

-   **Google Analytics Data API**
-   **Google Analytics Admin API**

## Step 4: Set up the OAuth consent screen

Under **APIs & Services → OAuth consent screen**, fill in the app name and your e-mail address:

-   **Internal** is available if you use Google Workspace and only people in your organisation will sign in.
-   **External** works for any Google account. While the app's publishing status is **Testing**, add yourself under **Test users**.

## Step 5: Create the OAuth client

1.  Go to **APIs & Services → Credentials → Create credentials → OAuth client ID**.
2.  Choose the application type **Web application**.
3.  Under **Authorized redirect URIs**, add the redirect URI shown on Insightor's **Google account** tab. It must match exactly, including `https://` and `www.` if your site uses it.
4.  Click **Create** and copy the **Client ID** and **Client secret**.

## Step 6: Sign in from Insightor

1.  Back on Insightor's **Google account** tab, paste the **Client ID** and **Client secret**.
2.  Click **Sign in with Google** and sign in with the Google account that can see your site's Google Analytics.
3.  Allow Insightor to read your Google Analytics data. It only asks to read your statistics; it can't change anything.

You return to WordPress with _"Connected as [you@example.com](mailto:you@example.com). Now choose the Google Analytics property of this site."_

## Step 7: Choose your site's property

1.  Under **This site's property**, choose your site's **Google Analytics property**.
2.  Leave **Use its measurement ID for tracking** on if you want Insightor to fill in the measurement ID of the property's web stream for you.
3.  Click **Save settings**.

Then open **Insightor → Statistics**. See [Seeing your statistics in WordPress with Insightor](/products/wordpress-plugins/insightor-statistics/).

## If something goes wrong

-   _**"Google did not connect: …"**_ followed by Google's reason. Most often the redirect URI in your OAuth client doesn't match exactly, or your Google account isn't a test user of the app.
-   _**"This Google account has no Google Analytics 4 property yet."**_ Create a property at analytics.google.com, or sign in with the Google account that has access to it.
-   _**"The connected Google account cannot read this Google Analytics property."**_ Choose another property, or connect an account that has access.
-   _**"Google access was withdrawn or has expired. Connect the Google account again."**_ Sign in again on the **Google account** tab. Google ends the sign-ins of apps whose publishing status is **Testing** after 7 days. To stay connected, set your consent screen's publishing status to **In production**, or use **Internal** with Google Workspace. Google may then warn that it hasn't verified your app when you sign in; it's your own app, so you can continue.
-   _**"Google Analytics limits how many reports a property can ask for per hour; try again in a while."**_ Wait a while, and consider keeping statistics longer under **Settings → Access and display → Keep statistics for (minutes)**.

## Disconnect

On the **Google account** tab, click **Disconnect** and confirm. Statistics stop showing in WordPress, and access is withdrawn at Google. Tracking continues with your measurement ID.

## Good to know

-   The client secret and Google's access are stored encrypted on your site. They aren't sent to Phluit.
-   On a multisite network, a network administrator can connect Google once under **Network Admin → Insightor**. Every site can use that connection and chooses its own property.
-   Statistics are kept for 60 minutes by default, so Insightor asks Google less often. Visitors right now refresh every minute.
