# Get Funnel Analysis — Amplitude

> Compute conversion rates across an ordered (or unordered/sequential) set of funnel steps over a date range from the Amplitude Dashboard REST API. Provide one event definition per funnel step. Example: call with…

- Key: `amplitude-get-funnel-analysis`
- Type: Action (Read-only)
- Version: 0.0.2
- App: Amplitude (`amplitude`) — https://pipedream.com/apps/amplitude.md
- This page (HTML): https://pipedream.com/apps/amplitude/actions/get-funnel-analysis
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/amplitude/actions/get-funnel-analysis/get-funnel-analysis.mjs

## Description

Compute conversion rates across an ordered (or unordered/sequential) set of funnel steps over a date range from the Amplitude Dashboard REST API. Provide one event definition per funnel step. Example: call with `events=["{\"event_type\":\"Sign Up\"}","{\"event_type\":\"Purchase\"}"]`, `startDate="20240706"`, `endDate="20240805"` -> returns `{data: [{stepByStep: [...], cumulative: [...], eventCount: 4200}, ...]}` (one entry per step). [See the documentation](https://amplitude.com/docs/apis/analytics/dashboard-rest#funnel-analysis).

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `events` | `string[]` | Yes | Array of JSON-encoded event definitions, one per funnel step, in order (each becomes a repeated e param). Example: ["{\"event_type\":\"Sign Up\"}","{\"event_type\":\"Purchase\"}"]. |
| `startDate` | `string` | Yes | Start date, inclusive, in YYYYMMDD format (the start param). Example: 20240706. |
| `endDate` | `string` | Yes | End date, inclusive, in YYYYMMDD format (the end param). Example: 20240805. |
| `mode` | `string` | No | Funnel step ordering (the mode param). One of ordered, unordered, sequential. Defaults to ordered. |
| `newOrActive` | `string` | No | Restrict to new or active users (the n param). |
| `interval` | `integer` | No | Time interval (the i param). One of -300000 (realtime), -3600000 (hourly), 1 (daily), 7 (weekly), 30 (monthly). |
| `segmentDefinitions` | `string` | No | JSON-encoded array of segment definitions (the s param). Example: [{"prop":"country","op":"is","values":["US"]}]. |
| `groupBy` | `string` | No | A single property name to group results by (the g param). Funnels support at most one group-by. |
| `conversionWindowSeconds` | `integer` | No | Conversion window in seconds (the cs param). Defaults to 2592000 (30 days). |
| `limit` | `integer` | No | Maximum number of grouped values to return (the limit param). Min 1, max 1000. Defaults to 100. Amplitude has no cursor for this endpoint — values beyond this cap are silently dropped by the API, not just this tool. If more than limit distinct group-by values may exist, raise this toward 1000 or narrow with Segment Definitions/Group By. |

## Run it

**MCP**

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

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

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "amplitude-get-funnel-analysis",
  arguments: {
    events: ["Events"],
    startDate: "Start Date",
  },
})
```

**TypeScript**

```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: "amplitude-get-funnel-analysis",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    amplitude: { authProvisionId: "apn_xxxxxxx" },
    events: ["Events"],
    startDate: "Start Date",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "amplitude-get-funnel-analysis",
    "configured_props": {
      "amplitude": { "authProvisionId": "apn_xxxxxxx" },
      "events": ["Events"],
      "startDate": "Start Date"
    }
  }'
```

---

- App: https://pipedream.com/apps/amplitude.md · All apps: https://pipedream.com/apps
