> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alana.shopping/llms.txt
> Use this file to discover all available pages before exploring further.

# Analytics Tools

> Search analytics, query performance, and recommendation stats.

## get\_search\_analytics

Retrieve aggregated search analytics for your catalog.

**Parameters:**

| Parameter    | Type    | Required | Description                                    |
| ------------ | ------- | -------- | ---------------------------------------------- |
| `days`       | integer | No       | Lookback window in days (default: 30, max: 90) |
| `catalog_id` | string  | No       | Filter to a specific catalog                   |

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://app.alana.shopping/api/mcp/sse" \
    -H "Authorization: Bearer sk_live_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{"method":"tools/call","params":{"name":"get_search_analytics","arguments":{"days":30}}}'
  ```

  ```javascript JavaScript theme={null}
  const result = await client.callTool({
    name: "get_search_analytics",
    arguments: { days: 30 },
  });
  console.log(result.content[0].text);
  ```

  ```python Python theme={null}
  result = await session.call_tool(
      "get_search_analytics",
      arguments={"days": 30},
  )
  print(result.content[0].text)
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "period_days": 30,
  "total_queries": 18420,
  "zero_result_rate": 0.032,
  "avg_results_per_query": 12.4,
  "top_queries": [
    { "query": "cotton t-shirt", "count": 842 },
    { "query": "running shoes", "count": 671 }
  ]
}
```

***

## get\_query\_performance

Get performance metrics for specific search queries.

**Parameters:**

| Parameter | Type      | Required | Description                   |
| --------- | --------- | -------- | ----------------------------- |
| `queries` | string\[] | Yes      | Queries to analyze (max: 20)  |
| `days`    | integer   | No       | Lookback window (default: 30) |

<CodeGroup>
  ```javascript JavaScript theme={null}
  const result = await client.callTool({
    name: "get_query_performance",
    arguments: {
      queries: ["cotton t-shirt", "running shoes"],
      days: 30,
    },
  });
  ```

  ```python Python theme={null}
  result = await session.call_tool(
      "get_query_performance",
      arguments={
          "queries": ["cotton t-shirt", "running shoes"],
          "days": 30,
      },
  )
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "queries": [
    {
      "query": "cotton t-shirt",
      "count": 842,
      "avg_results": 18,
      "click_through_rate": 0.41,
      "zero_results": false
    }
  ]
}
```

***

## get\_recommendation\_stats

Retrieve statistics on product recommendations and their effectiveness.

**Parameters:**

| Parameter    | Type    | Required | Description                                      |
| ------------ | ------- | -------- | ------------------------------------------------ |
| `days`       | integer | No       | Lookback window (default: 30)                    |
| `product_id` | string  | No       | Filter to recommendations for a specific product |

<CodeGroup>
  ```javascript JavaScript theme={null}
  const result = await client.callTool({
    name: "get_recommendation_stats",
    arguments: { days: 30 },
  });
  ```

  ```python Python theme={null}
  result = await session.call_tool(
      "get_recommendation_stats",
      arguments={"days": 30},
  )
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "period_days": 30,
  "total_recommendations_shown": 94200,
  "click_through_rate": 0.087,
  "conversion_rate": 0.012,
  "top_recommended_products": [
    { "product_id": "SKU-001", "impressions": 4820, "clicks": 389 }
  ]
}
```
