# Directus + Google Analytics — Pipedream Connect

> Connect a user's Directus and Google Analytics accounts and expose tools for both apps directly in your product or your agent.

- Apps: Directus (`directus`) + Google Analytics (`google_analytics`)
- This page (HTML): https://pipedream.com/apps/directus/integrations/google-analytics
- One `external_user_id` owns both connected accounts, and each account stays independently revocable.

## One session, both toolsets (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: directus,google_analytics`
- `x-pd-app-slug` takes a comma-separated list, so `directus,google_analytics` is one session on one transport. Both toolsets arrive from a single `listTools()`, and a tool is called exactly as it would be in a single-app session.

```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": "directus,google_analytics",
      },
    },
  },
)

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

const { tools } = await mcp.listTools()

// One list, both toolsets: Directus and Google Analytics tools arrive
// together, each keyed by its own app's slug.

// 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)

## Both apps from your backend

```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 externalUserId = "{external_user_id}" // any stable ID for this user in your system

const [directusTools, googleAnalyticsTools] =
  await Promise.all([
    pd.components.list({ app: "directus" }),
    pd.components.list({ app: "google_analytics" }),
  ])

// One external user owns both connected accounts, so either app's tools
// run on their behalf with the same externalUserId.
```

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

## Directus

- API slug: `directus` (use in MCP headers and tool keys)
- Auth: API key (Pipedream-managed)
- Categories: Infrastructure & Cloud
- Website: https://directus.io
- App page (HTML): https://pipedream.com/apps/directus
- Tools: 0 actions · 0 triggers

Full tool list, API proxy, and SDK quickstart: https://pipedream.com/apps/directus.md

## Google Analytics

- 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`
- App page (HTML): https://pipedream.com/apps/google-analytics
- Tools: 6 actions · 1 trigger

Full tool list, API proxy, and SDK quickstart: https://pipedream.com/apps/google-analytics.md

### Actions (6)

- [Create GA4 Property](https://pipedream.com/apps/google-analytics/actions/create-ga4-property.md) — `google_analytics-create-ga4-property`
- [Create Key Event](https://pipedream.com/apps/google-analytics/actions/create-key-event.md) — `google_analytics-create-key-event`
- [List Account Options](https://pipedream.com/apps/google-analytics/actions/list-account-options.md) — `google_analytics-list-account-options`
- [List Property Options](https://pipedream.com/apps/google-analytics/actions/list-property-options.md) — `google_analytics-list-property-options`
- [Run Report](https://pipedream.com/apps/google-analytics/actions/run-report.md) — `google_analytics-run-report`
- [Run Report in GA4](https://pipedream.com/apps/google-analytics/actions/run-report-in-ga4.md) — `google_analytics-run-report-in-ga4`

### Triggers (1)

- [New Page Opened (GA4)](https://pipedream.com/apps/google-analytics/triggers/page-opened.md) — `google_analytics-page-opened`

---

- Directus: https://pipedream.com/apps/directus.md · Google Analytics: https://pipedream.com/apps/google-analytics.md
- All apps: https://pipedream.com/apps — index: https://pipedream.com/llms.txt
- Pipedream docs for agents: https://pipedream.com/docs/llms.txt
