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

# Analytics

> View platform and post-level analytics from the command line

<Frame>
  <img src="https://mintcdn.com/forceplay/B3-2tTHDDqEkLyvR/images/brand/analytics.svg?fit=max&auto=format&n=B3-2tTHDDqEkLyvR&q=85&s=4cf8271e868f7030b16235d91e87b7f1" alt="PostQueen analytics: engagement chart, followers, impressions and video views" width="620" height="360" data-path="images/brand/analytics.svg" />
</Frame>

Ask her how last week went and she answers with numbers, per channel or per post.

## Platform Analytics

Get analytics for a specific integration/channel. Returns metrics like followers, impressions, and engagement over time.

```bash theme={"system"}
postqueen analytics:platform <integration-id>
```

### Options

| Flag         | Description                              |
| ------------ | ---------------------------------------- |
| `-d, --date` | Number of days to look back (default: 7) |

### Examples

```bash theme={"system"}
# Last 7 days (default)
postqueen analytics:platform your-integration-id

# Last 30 days
postqueen analytics:platform your-integration-id -d 30

# Last 90 days
postqueen analytics:platform your-integration-id -d 90
```

The response is an array of metrics, each with daily data points:

```json theme={"system"}
[
  {
    "label": "Followers",
    "data": [
      { "total": "1250", "date": "2026-07-01" },
      { "total": "1280", "date": "2026-07-02" }
    ],
    "percentageChange": 2.4
  },
  {
    "label": "Impressions",
    "data": [
      { "total": "5000", "date": "2026-07-01" },
      { "total": "5200", "date": "2026-07-02" }
    ],
    "percentageChange": 4.0
  }
]
```

<Note>
  The metrics returned depend on the platform. For example, X returns followers and impressions, while YouTube may return subscribers and views.
</Note>

## Post Analytics

Get analytics for a specific published post. Returns metrics like likes, comments and impressions.

```bash theme={"system"}
postqueen analytics:post <post-id>
```

### Options

| Flag         | Description                              |
| ------------ | ---------------------------------------- |
| `-d, --date` | Number of days to look back (default: 7) |

### Examples

```bash theme={"system"}
# Last 7 days (default)
postqueen analytics:post your-post-id

# Last 30 days
postqueen analytics:post your-post-id -d 30
```

The response follows the same format as platform analytics:

```json theme={"system"}
[
  {
    "label": "Likes",
    "data": [
      { "total": "150", "date": "2026-07-01" },
      { "total": "175", "date": "2026-07-02" }
    ],
    "percentageChange": 16.7
  },
  {
    "label": "Comments",
    "data": [
      { "total": "25", "date": "2026-07-01" },
      { "total": "30", "date": "2026-07-02" }
    ],
    "percentageChange": 20.0
  }
]
```

<Tip>
  Post analytics are only available for published posts. Draft or queued posts will not return analytics data. An empty array `[]` means either the post has not been published yet or that network does not report per-post metrics; run `postqueen posts:list` to confirm the post has a release ID.
</Tip>

### When a post shows `{"missing": true}`

If `analytics:post` returns `{"missing": true}`, the post was published but the platform did not return a usable post ID, so it is not connected to its published content yet. Resolve it, then retry:

```bash theme={"system"}
# 1. List available content from the provider
postqueen posts:missing <post-id>

# 2. Connect the correct content to the post
postqueen posts:connect <post-id> --release-id "7321456789012345678"

# 3. Analytics will now work
postqueen analytics:post <post-id>
```

<Note>
  The full error table: [Troubleshooting](/cli/troubleshooting).
</Note>

## Scripting with Analytics

Extract specific metrics using `jq`. Every analytics command prints a one-line header before the JSON, so `tail -n +2` drops it first; the header line is not JSON.

```bash theme={"system"}
# Get just the follower count trend
postqueen analytics:platform integration-id -d 30 | tail -n +2 | jq '.[] | select(.label=="Followers")'

# Get percentage changes for all metrics
postqueen analytics:platform integration-id | tail -n +2 | jq '.[] | {label, percentageChange}'

# Get the latest total for each post metric
postqueen analytics:post post-id | tail -n +2 | jq '.[] | {label, latest: .data[-1].total}'
```
