> ## Documentation Index
> Fetch the complete documentation index at: https://6f524b4-productmetrics.manicule.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.
> For every page in one file, fetch https://6f524b4-productmetrics.manicule.dev/docs/llms-full.txt (large).
> To search and read these docs as tools, connect the MCP server at https://6f524b4-productmetrics.manicule.dev/docs/api/mcp.
> Every agent surface: https://6f524b4-productmetrics.manicule.dev/docs/.well-known/llms-manifest.json

# Product Metrics in Claude Code (/docs/integrations/claude-code)

<!-- agent-signals: reading_time_min: 5 · est_tokens: 1801 · updated: 2026-11-16 -->
Related: [Product Metrics in ChatGPT](/docs/integrations/chatgpt.md), [Product Metrics in Claude](/docs/integrations/claude.md), [Product Metrics in Codex](/docs/integrations/codex.md), [Product Metrics in Cursor](/docs/integrations/cursor.md)

> Add the Product Metrics MCP server, skills and productmetrics CLI to Claude Code, then set up tracking and analyse Google Ads from the terminal.

Claude Code works with Product Metrics in three ways:

* **MCP server** (`https://www.productmetrics.io/mcp`): reads your stores, products and Google Ads account, and runs setup through the API.
* **Skills**: teach Claude the exact steps for tasks such as setting up tracking.
* **`productmetrics` CLI**: the same API as commands with JSON output.

You sign in once in your browser. There is no API key.

## Install

### 1. Add the MCP server

```bash
claude mcp add --transport http product-metrics \
  https://www.productmetrics.io/mcp
```

Add `--scope user` to use it in every project, or `--scope project` to share it with your team through `.mcp.json`. `productmetrics mcp-config --client claude` prints the same command.

### 2. Install the skills

From the project where you run Claude Code:

```bash
npx skills add https://www.productmetrics.io/docs \
  --skill '*' \
  --agent claude-code \
  -y
```

This installs `set-up-tracking`, `connect-google-ads`, `check-tracking`, `bid-on-profit` and `analyse-google-ads`. Add `--global` to install them for every project. Needs Node.js 22.20 or later. See [Install skills](/docs/agent-skills/install).

### 3. Install the productmetrics CLI (optional)

Install it from npm (Node.js 22 or later), then check it:

```bash
npm install -g @productmetrics/cli
productmetrics --version
```

To run it once without installing, use `npx @productmetrics/cli` in place of `productmetrics`. Claude Code runs `productmetrics` like any other command.

## Authenticate

**MCP server.** Start Claude Code and run `/mcp`. Choose **product-metrics** and pick **Authenticate**.

Your browser opens the Product Metrics consent page: sign in (or choose **Continue with Google** to create an account), check what Claude Code **Can read** and **Can change**, and click **Connect Claude Code**.

**productmetrics CLI.** Run this in your own terminal, not through Claude:

```bash
# opens the browser and waits up to 5 minutes
productmetrics login
# which API, signed in or not, scopes, expiry
productmetrics status
```

`productmetrics` renews its token on its own for 30 days. In Claude Code's shell `productmetrics` never prompts or opens a browser; to set that in every shell, see [CLI for agents](/docs/cli/for-agents).

## How it works

* **Browser steps come back as a link.** Google consent, a store install or checkout needs you in a browser. Claude gives you the link, waits, then reads the setup status again.
* **Analysis tools only read.** They never change Google Ads or your store. Setup runs through `search` and `execute`, and operations that delete something run only after you confirm.
* **Secrets stay out of the chat.** Fields such as a store setup token never reach the assistant through MCP.

Every tool: [MCP tools](/docs/mcp/tools). Every skill: [Skills](/docs/agent-skills/overview).

## What you can ask

Run `/mcp` to sign in, check the connection or reconnect. Type a skill's name to run it, for example `/set-up-tracking`; Claude also loads a skill when your request matches it. Or just ask:

```text
> Where is my Product Metrics setup, and what is the next step?
→ execute (GET /setup/status), or productmetrics setup get-status --json

> Connect my Shopify store to Product Metrics.
→ execute (POST /companies/:companyId/stores), or productmetrics stores connect
  --company-id <company_id> --provider shopify --json
  then gives you the link to approve the install in Shopify Admin

> Create the Product Metrics conversion actions in Google Ads.
→ execute (POST /properties/:propertyId/google-ads/conversion-actions),
  or productmetrics google-ads create-conversion-actions --property-id <property_id>
    --company-id <company_id> --json

> Which products lose money after ads this month?
→ list_properties, then get_poas_report (level: product,
  only_unprofitable: true)

> Why did my Google Ads ROAS drop last week?
→ list_properties, then explain_google_ads_change
```

## Configuration

### Project config

`claude mcp add --scope project` writes `.mcp.json` in the repository root. You can also create it by hand:

```json title=".mcp.json"
{
  "mcpServers": {
    "product-metrics": {
      "type": "http",
      "url": "https://www.productmetrics.io/mcp"
    }
  }
}
```

### Pin one store

For a project that should only see one store, add the property to the URL. The analysis tools then read that store without asking; `search` and `execute` still work on your whole account.

```bash
claude mcp add --transport http product-metrics \
  "https://www.productmetrics.io/mcp?selectedAccountPropertyId=<propertyId>"
```

### productmetrics settings

`PM_AGENT`, `PM_TOKEN` for CI and `PM_API_URL`: [CLI overview](/docs/cli/overview) and [Authentication](/docs/cli/authentication).

## Troubleshooting

| Problem                                                                           | Fix                                                                                                           |
| --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| **product-metrics** shows as failed or needs authentication in `/mcp`             | Pick **Authenticate** again and finish the sign-in in the browser.                                            |
| "This connection expired or was removed; connect Product Metrics again."          | Run `/mcp` and authenticate again. If that fails, `claude mcp remove product-metrics` and add it again.       |
| "This connection only has MCP access, so it cannot call the Product Metrics API." | Remove the server, add it again and allow everything the consent page shows.                                  |
| "The MCP server is not enabled for this account yet."                             | Ask Product Metrics support to turn it on for your account.                                                   |
| "This property needs a Product Metrics Pro subscription for the MCP server."      | Upgrade that store to Pro, or ask about another store.                                                        |
| `productmetrics` exits `3`                                                        | Not signed in or missing a scope. Run `productmetrics login` in your own terminal; the hint names the scopes. |
| `productmetrics` exits `4`                                                        | A person must finish a step in a browser. Open `next_action.url`, then ask Claude to check the status again.  |
| Claude doesn't use a skill                                                        | Run `npx skills list` and check it is installed for `claude-code`, then restart Claude Code.                  |

## Where next

* [Setup and usage](/docs/mcp/connect): how sign-in works, every client
* [MCP tools](/docs/mcp/tools): every tool and argument
* [Skills](/docs/agent-skills/overview): what each skill does
* [CLI for agents](/docs/cli/for-agents): `--json`, exit codes and safe retries
* [Cursor](/docs/integrations/cursor) · [Codex](/docs/integrations/codex)
