# Google Analytics — Pipedream Connect

> Google Analytics enables you to measure and report on user activity on websites, web and mobile apps, and internet-connected devices.

- API slug: `google_analytics` (use in MCP headers and tool keys)
- Auth: OAuth (Pipedream-managed)
- Categories: Data Analytics
- Website: https://analytics.google.com
- Managed OAuth scopes: `email` · `profile` · `https://www.googleapis.com/auth/analytics.edit` · `https://www.googleapis.com/auth/analytics.readonly`
- This page (HTML): https://pipedream.com/apps/google-analytics
- Tools: 6 actions · 1 trigger

## Connect via MCP (recommended)

- Endpoint: `https://remote.mcp.pipedream.net/v3`
- Headers: `Authorization: Bearer <token>` · `x-pd-project-id` · `x-pd-environment` · `x-pd-external-user-id` · `x-pd-app-slug: google_analytics`

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "google_analytics",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// e.g. run Create GA4 Property:
const result = await mcp.callTool({
  name: "google_analytics-create-ga4-property",
  arguments: {
    account: "Account",
    displayName: "Display Name",
  },
})
```

Docs: [MCP guide](https://pipedream.com/docs/connect/mcp/developers.md)

## API proxy

For a Google Analytics endpoint with no pre-built tool, the proxy forwards your request with the connected user's credentials attached.

```bash
# The path segment is the target URL, URL-safe base64 encoded:
# https://www.googleapis.com/oauth2/v1/userinfo

curl "https://api.pipedream.com/v1/connect/{project_id}/proxy/aHR0cHM6Ly93d3cuZ29vZ2xlYXBpcy5jb20vb2F1dGgyL3YxL3VzZXJpbmZv?external_user_id={external_user_id}&account_id=apn_xxxxxxx" \
  -H "Authorization: Bearer {access_token}" \
  -H "x-pd-environment: production"
```

Docs: [API proxy guide](https://pipedream.com/docs/connect/api-proxy.md)

## SDK

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "google_analytics-create-ga4-property",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    google_analytics: { authProvisionId: "apn_xxxxxxx" },
    account: "Account",
    displayName: "Display Name",
  },
})
```

Docs: [Managed auth guide](https://pipedream.com/docs/connect/managed-auth/quickstart.md) · [Tools guide](https://pipedream.com/docs/connect/components.md)

## Actions (6)

### `google_analytics-create-ga4-property` — Create GA4 Property (Write)

Creates a new GA4 property. See the documentation

Full schema: https://pipedream.com/apps/google-analytics/actions/create-ga4-property.md

### `google_analytics-create-key-event` — Create Key Event (Write)

Creates a new key event. See the documentation

Full schema: https://pipedream.com/apps/google-analytics/actions/create-key-event.md

### `google_analytics-list-account-options` — List Account Options (Read-only)

Retrieves available options for the Account field.

Full schema: https://pipedream.com/apps/google-analytics/actions/list-account-options.md

### `google_analytics-list-property-options` — List Property Options (Read-only)

Retrieves available options for the Property field.

Full schema: https://pipedream.com/apps/google-analytics/actions/list-property-options.md

### `google_analytics-run-report` — Run Report (Read-only)

Return report metrics based on a start and end date. See the documentation

Full schema: https://pipedream.com/apps/google-analytics/actions/run-report.md

### `google_analytics-run-report-in-ga4` — Run Report in GA4 (Write)

Returns a customized report of your Google Analytics event data. Reports contain statistics derived from data collected by the Google Analytics tracking code. See the documentation

Full schema: https://pipedream.com/apps/google-analytics/actions/run-report-in-ga4.md

## Triggers (1)

### `google_analytics-page-opened` — New Page Opened (GA4) (Polling)

Emit new event when a page is viewed (uses GA4 Data API)

Full schema: https://pipedream.com/apps/google-analytics/triggers/page-opened.md

---

- All apps: https://pipedream.com/apps — index: https://pipedream.com/llms.txt
- Pipedream docs for agents: https://pipedream.com/docs/llms.txt
