> ## 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.

# Feed Analytics

> Track feed consumption metrics — fetches, unique consumers, error rates, and frequency.

## Overview

Feed analytics give you visibility into how external platforms are consuming your product feeds — how often, by whom, and with what success rate.

## Endpoint

```
GET /api/v1/feeds/{platform}/analytics
```

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://app.alana.shopping/api/v1/feeds/google/analytics" \
    -H "X-API-Key: sk_live_your_api_key"
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch(
    "https://app.alana.shopping/api/v1/feeds/google/analytics",
    { headers: { "X-API-Key": "sk_live_your_api_key" } }
  );
  const analytics = await res.json();
  console.log(analytics.total_fetches, analytics.unique_consumers);
  ```

  ```python Python theme={null}
  import requests

  res = requests.get(
      "https://app.alana.shopping/api/v1/feeds/google/analytics",
      headers={"X-API-Key": "sk_live_your_api_key"},
  )
  analytics = res.json()
  print(analytics["total_fetches"], analytics["unique_consumers"])
  ```
</CodeGroup>

## Response

```json theme={null}
{
  "platform": "google",
  "period": {
    "from": "2026-02-17T00:00:00Z",
    "to": "2026-03-17T23:59:59Z"
  },
  "total_fetches": 2847,
  "unique_consumers": 3,
  "avg_frequency_hours": 6.2,
  "error_rate": 0.004,
  "last_fetch_at": "2026-03-17T11:45:00Z",
  "product_count_trend": [
    { "date": "2026-03-15", "count": 1420 },
    { "date": "2026-03-16", "count": 1428 },
    { "date": "2026-03-17", "count": 1432 }
  ]
}
```

## Response Fields

| Field                 | Type     | Description                                     |
| --------------------- | -------- | ----------------------------------------------- |
| `total_fetches`       | integer  | Total feed downloads in the period              |
| `unique_consumers`    | integer  | Number of distinct consumer IPs/agents          |
| `avg_frequency_hours` | float    | Average hours between fetches                   |
| `error_rate`          | float    | Fraction of requests that returned errors (0–1) |
| `last_fetch_at`       | ISO 8601 | Timestamp of the most recent fetch              |
| `product_count_trend` | array    | Daily product count snapshots                   |

## Query Parameters

| Parameter | Default | Description                 |
| --------- | ------- | --------------------------- |
| `days`    | `30`    | Lookback window (max: `90`) |
| `from`    | —       | Start date (ISO 8601)       |
| `to`      | —       | End date (ISO 8601)         |

## Data Retention

Analytics data is retained for 90 days. Use the `days` parameter or `from`/`to` range to query any window within the retention period.

## All Platforms Summary

To get analytics for all platforms at once:

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://app.alana.shopping/api/v1/feeds/analytics" \
    -H "X-API-Key: sk_live_your_api_key"
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch(
    "https://app.alana.shopping/api/v1/feeds/analytics",
    { headers: { "X-API-Key": "sk_live_your_api_key" } }
  );
  const summary = await res.json();
  // Returns array of analytics per platform
  ```

  ```python Python theme={null}
  import requests

  res = requests.get(
      "https://app.alana.shopping/api/v1/feeds/analytics",
      headers={"X-API-Key": "sk_live_your_api_key"},
  )
  summary = res.json()
  for platform in summary["platforms"]:
      print(platform["platform"], platform["total_fetches"])
  ```
</CodeGroup>
