# CLI

Add tracking to a project, check a deploy in CI, and send sitemaps and release notes from your build.

The Ultanimus CLI adds tracking to a project, checks that a deployed page tracks, sends sitemaps and release notes from your build, shows your numbers, what slows your pages down, the errors visitors hit and what they searched on Google, and downloads your raw events. It also keeps a site's goals, funnels and dashboards in a file you commit. It needs Node 20 or later, or Bun.

```bash
npx @ultanimus/cli init
```

Run it with `npx` as above, or install it once with `npm install -g @ultanimus/cli` and run `ultanimus`. The examples below use the installed name. To see where it fits in your work, read the [CLI guide](/docs/cli/guide).

## Sign in

```bash
ultanimus login
```

The CLI prints a code and opens your browser. Check that the browser shows the same code, pick the organization, and approve. Only owners and admins can approve, since approving creates an API key. A code lasts 10 minutes and works once.

The CLI keeps the key in Keychain on macOS and in the Secret Service on Linux. Where neither exists, it writes a file that only your user can read. The key shows under **Integrations → API keys** in your organization settings as **CLI on** your computer's name, with a CLI label. Signing in again replaces it, and `ultanimus logout` revokes it.

```bash
ultanimus whoami
```

`whoami` shows the organization, plan and permissions of the key in use, who created it, and where it comes from. It exits with 1 when there is no key or the key stopped working, so a CI job can check its key first.

## What the key can do

On Insight and Foresight, you pick the key's permissions when you approve. On Glance, the key can add sites and send their sitemaps, which covers everything except marking releases and reading stats.

| Command | Permission it needs | On Glance |
|---|---|---|
| `init` | Add sites (`sites:write`) | Yes |
| `check` | Any key | Yes |
| `sitemap push` | Add sites (`sites:write`) | Yes |
| `annotate`, `push` | Change dashboards (`dashboards:write`) | No |
| `push --prune` | Delete dashboards (`dashboards:delete`) | No |
| `pull`, `diff` | Read stats (`stats:read`), which every key has | No |
| `stats`, `vitals`, `load`, `errors`, `search`, `export` | Read stats (`stats:read`), which every key has | No |

`login` never asks for Delete dashboards. For `push --prune`, run `login` again and tick **Delete dashboards** on the page that approves it. In CI, create a key with it under **Integrations → API keys** in your organization settings, and set it as `ULTANIMUS_API_KEY`.

## Add tracking

Run `init` in your project folder.

```bash
ultanimus init
```

### Find the framework

`init` reads `package.json` and picks Next.js, Expo, React Native, React, SvelteKit, Nuxt, Astro or plain HTML. A folder with an Xcode project is a Swift app. Pass `--framework` when it guesses wrong.

### Pick the site

It lists your sites and offers to add one. Pass `--site` with a domain or site ID to skip the question, or `--domain` to use the site with that domain and add it when it is missing.

### Add the code

For Next.js and React, it installs `@ultanimus/next` or `@ultanimus/react` with your package manager and renders the component in your root layout, or in the root route of TanStack Start and React Router. For SvelteKit, Astro and plain HTML, it adds the script tag to `src/app.html`, the layout's `<head>` or `index.html`. For Nuxt, it adds the script to `app.head` in `nuxt.config`, unless the config already has an `app` key. When it cannot find the file, it prints the code to paste.

For an Expo or React Native app, it installs `@ultanimus/react-native`, with `npx expo install` in an Expo app. With Expo Router, it renders the component in the root layout, next to the navigator or inside the layout's outer element. With React Navigation, it renders it inside `NavigationContainer` with your app's ID from `app.json` or the native project. Without either, it prints the code to paste. Then it names the app IDs to add under Apps in the site's settings.

For a Swift app, it adds the [Swift package](/docs/install/swift) to the app target in your Xcode project and calls `start` where the app launches, in your `App` or your app delegate. It leaves a project with several apps, or one that XcodeGen or Tuist generates, for you, and prints the steps. Then it names the bundle IDs to add under Apps.

Pass `--vitals` to measure [Web vitals](/docs/dashboard/vitals) and `--load` to measure [Load](/docs/dashboard/load). On a project that already tracks, they turn the add-on on in the code that is there. Apps take neither.

### Save the site

It writes the site ID to `ultanimus.config.json`, so `check`, `sitemap push` and `annotate` know which site to use. Commit the file. The site ID is public, since every visitor's browser sees it.

### Wait for the first event

Deploy the site and open it. Visits from `localhost` never count, so the wait ends when the live site sends its first event. Press Ctrl+C to stop waiting, or pass `--no-wait` to skip it.

An app skips the wait, since development builds never count. Run it in Expo Go, on a simulator or from Xcode and watch its events under Test events in the site's settings. [Development builds](/docs/mobile/development) explains why.

## Check a deploy

```bash
ultanimus check https://example.com
```

`check` loads the page and checks that:

- the HTML loads the script once, with this project's site ID
- the page's Content Security Policy allows the script and the requests it sends
- the site sent an event in the last day

It also lists the add-ons the script turns on, with the share of page loads each one measures, and warns about a share it cannot read.

It exits with 1 when a check fails, so a deploy can stop on it. The React package adds the script after the page loads, so its HTML shows no script. There, events arriving in the last day are enough to pass.

The events check needs a key. Without one, `check` still runs the other checks and prints a warning for events.

## Use it in CI

Set `ULTANIMUS_API_KEY` to an API key instead of signing in. Create one on the API keys page, and keep it in your CI's secret settings.

```yaml
- name: Check tracking
  run: npx @ultanimus/cli check https://example.com
  env:
    ULTANIMUS_API_KEY: ${{ secrets.ULTANIMUS_API_KEY }}
```

On Glance, the API keys page creates no keys, so run `check` without one. It checks the page and its policy, and skips the events check.

## Send sitemaps

```bash
ultanimus sitemap push public/sitemap.xml
```

Use it when we cannot fetch your sitemap, like a site behind a login or bot protection. Pass up to 20 files. The upload replaces the pages you had, the same as an upload in the site's settings. It works once the site has sent its first event, which shows the domain is yours. See [Sitemaps](/docs/tracking/sitemaps).

## Mark a release

```bash
ultanimus annotate "Shipped the new pricing page"
```

The note shows on the charts at the current time. Pass `--at 2026-10-12T14:30` for another time, in the site's timezone. See [Annotations](/docs/tracking/annotations).

## Keep goals, funnels and dashboards in code

`pull`, `diff` and `push` keep a site's goals, funnels and dashboards in `ultanimus.config.json`. A change then goes through code review like any other, and a staging site and a production site can share one setup.

```bash
ultanimus pull
```

`pull` writes the site's goals, funnels and dashboards into the file. Each goal and funnel carries a key, and each dashboard a slug, which tie it to the site. The file never holds database IDs.

```json
{
  "site": "example.com",
  "goals": [
    { "key": "signed-up", "name": "Signed up", "kind": "event", "match": "signup" },
    { "key": "saw-pricing", "name": "Saw pricing", "kind": "page", "match": "/pricing" }
  ],
  "funnels": [
    {
      "key": "signup",
      "name": "Signup",
      "steps": [{ "kind": "page", "match": "/pricing" }, { "kind": "event", "match": "signup" }],
      "within": "visit"
    }
  ],
  "dashboards": [
    {
      "slug": "growth",
      "name": "Growth",
      "widgets": [
        { "type": "kpi", "metric": "visitors", "x": 0, "y": 0, "w": 3, "h": 2 },
        { "type": "goal", "goal": "signed-up", "x": 3, "y": 0, "w": 3, "h": 5 }
      ]
    }
  ]
}
```

Edit the file, then see what a push would change.

```bash
ultanimus diff
```

```text
example.com · ultanimus.config.json

Goals
  ~ signed-up  Joined
      name: Signed up → Joined
  + trial  Started a trial · the event trial

Dashboards
  ~ growth  Growth
      widgets: 2 widgets → 3 widgets

! 1 item stays on the site, since the file does not list it: funnel checkout.
  Add --prune to delete it.

· 1 to create and 2 to update. Run ultanimus push to apply them.
```

`push` prints the same plan and asks before it saves. Then it saves every change or none of them. In CI, pass `--yes`, since there is no one to ask. Without a terminal and without `--yes`, `push` exits with 2 and changes nothing.

```bash
ultanimus push
```

- **Keys.** A push finds each item by its key. An item with no key matches the site's item with the same name, and a new one gets a key made from its name. Run `pull` after the push to write the new keys into the file, so a rename later updates the item instead of adding one.
- **Kinds the file leaves out.** A file without `dashboards` leaves the site's dashboards alone. `pull` writes only the kinds the file lists, or all three into a file that lists none.
- **Deletes.** Items the site has and the file does not list stay, and `diff` names them. `push --prune` deletes them, with a key that has Delete dashboards. A deleted dashboard takes its history and share links with it, so History cannot bring it back.
- **What a goal counts.** Changing a goal's `kind` or `match` replaces the goal under the same key, so dashboards and alerts that use the key keep working.
- **Checks.** The CLI checks the shape of the file before it sends anything, and names the file and the item when something is wrong. The server checks each item with the same rules as the editors in the dashboard, and applies your plan's limits.
- **Local changes.** `pull` replaces each item with the site's version and keeps the order of the file. It stops when the file has an item the site does not, so a goal you have not pushed yet stays. Push it first, or run `pull --force` to drop it.
- **History.** A push writes the same audit log entries as the editors, under the key's name, and dashboard changes show in History as made through the API. `diff` writes nothing.
- **One site per file.** To give another site the same setup, run `ultanimus push --site staging.example.com`.

In CI, show the plan on pull requests and apply it when the change lands on `main`. The [CLI guide](/docs/cli/guide#review-analytics-changes-like-code) has the full workflow.

## Read the numbers

```bash
ultanimus stats
```

`stats` prints the numbers on top of the dashboard for the last 30 days: visitors, visits, pageviews, views per visit, bounce rate and visit duration, each with its change against the 30 days before, then the five top pages and sources. Pass `--range` with `today`, `7d`, `90d` or `12mo` for another range, and `--json` to feed the numbers to a script. It reads the [Query API](/docs/api/query), so it needs Insight or Foresight.

## See what slows pages down

```bash
ultanimus vitals
ultanimus load
```

`vitals` prints the [Web vitals](/docs/dashboard/vitals) report: LCP, INP, CLS, FCP and TTFB at the 75th percentile with their ratings, whether the site passes Core Web Vitals, the five pages with the most slow loads, and the fixes ranked by the page loads they slow. Each fix names the element behind the slow loads. `load` prints the [Load](/docs/dashboard/load) audit: page weight, JavaScript, requests and server response, the third parties and heaviest pages, and the fixes ranked by the bytes they save. Both read the last 30 days. Pass `--range 7d` or `--range 90d` for another range.

Pass `--page` with a path to read one page. The path matches exactly, without the query string, the same as opening a page in the dashboard.

```bash
ultanimus vitals --page /pricing
```

`--prompt` prints the brief that Copy the fix prompt copies on the dashboard, and nothing else, so you can hand it straight to a coding agent.

```bash
ultanimus vitals --prompt | pbcopy
```

An agent that runs commands, such as Claude Code, can run `ultanimus vitals --prompt` itself and work through the list. Both commands need Insight or Foresight, and samples, which start when the script tag has `data-vitals` or `data-load`. `ultanimus init --vitals --load` adds both. They read the same report as the [Load and vitals API](/docs/api/audits).

## Find JavaScript errors

```bash
ultanimus errors
```

`errors` prints the [Errors](/docs/dashboard/errors) report for the last 30 days: the errors, the visitors and page views they hit, and the five busiest groups with the line of code each one starts from. Groups new in the range carry a `new` tag, and new groups outside the busiest five follow them. Pass `--range` with `7d` or `90d`, `--page` to read one page, and `--json` for up to 30 groups with their stacks and browsers.

With no errors in the range, it says when the last one came, or whether the add-on is on at all. Errors need `data-errors` on the script tag.

## See what people searched

```bash
ultanimus search
```

`search` prints the [Search Console](/docs/dashboard/search-console) report: clicks, impressions, click-through rate and average position against the period before, then the top 10 queries. A lower position is better, so an arrow down on position is green. The range ends on the last day Google reported, and the output names that day. Pass `--range` with `today`, `7d`, `90d` or `12mo`, `--limit` for up to 50 queries, and `--page` for the queries that showed one page.

Search Console is connected once per site, in the site's settings, by an owner or admin. Until then, `search` says so and exits with 0.

## Export events

```bash
ultanimus export --from 2026-10-01 --to 2026-10-31
```

`export` downloads every event of the site for those days, one row per event, as the [raw export](/docs/api/export) describes. It saves the file under the name the server gives, such as `example.com-events-2026-10-01-to-2026-10-31.csv`, in the current folder. `--to` defaults to today. CSV comes with Insight and Foresight. Pass `--format parquet` on Foresight, or `--format zip` for daily totals in the layout Plausible imports.

The CLI writes to a `.part` file and renames it only when the download is complete. If the export stops partway, it deletes the part and exits with 1, so a script never reads half a file. It never replaces a file that exists unless you pass `--force`. Pass `--out <file>` to pick the name, or `--out -` to pipe the rows into another tool.

```bash
ultanimus export --from 2026-10-01 --format parquet --out october.parquet
ultanimus export --from 2026-10-01 --out - | duckdb -c "SELECT name, count() FROM read_csv('/dev/stdin') GROUP BY name"
```

An organization runs one export at a time and at most 50 a day.

## Options

| Option | What it does |
|---|---|
| `--site <site>` | Use this site, by domain or site ID, instead of the one in `ultanimus.config.json`. |
| `--range <range>` | For `stats` and `search`, read `today`, `7d`, `30d`, `90d` or `12mo`. For `vitals`, `load` and `errors`, read `7d`, `30d` or `90d`. |
| `--page <path>` | For `vitals`, `load`, `errors` and `search`, read one page, such as `/pricing`. |
| `--prompt` | For `vitals` and `load`, print the agent prompt only. |
| `--limit <n>` | For `search`, how many queries to list, from 1 to 50. |
| `--from`, `--to` | For `export`, the first and last day, such as `2026-10-01`, in the site's time zone. |
| `--format <name>` | For `export`, `csv`, `parquet` or `zip`. |
| `--out <file>` | For `export`, where to save the file, or `-` for stdout. |
| `--force` | For `export`, replace a file that exists. For `pull`, drop items the site does not have. |
| `--prune` | For `diff` and `push`, delete what the site has and the file does not list. |
| `-y`, `--yes` | For `push`, apply without asking. |
| `--json` | Print JSON, for scripts. |
| `-h`, `--help` | Show help for a command. |
| `-v`, `--version` | Print the version. |

Exit codes are 0 when the command worked, 1 when it failed or a check failed, and 2 when the command or an option is wrong.

## Updates

To upgrade, run the install command again with `@latest`:

```bash
npm install -g @ultanimus/cli@latest
```

With pnpm, Yarn or Bun, run `pnpm add -g @ultanimus/cli@latest`, `yarn global add @ultanimus/cli@latest` or `bun add -g @ultanimus/cli@latest`. With npx, add `@latest` to the package, as in `npx @ultanimus/cli@latest init`. `ultanimus --version` prints the version you have.

When a newer version is out, the CLI ends with a note that names it and shows the command to upgrade, after `ultanimus --version` and help too. To turn the note off, set `ULTANIMUS_NO_UPDATE_CHECK=1`.

## Self-hosted

Set `ULTANIMUS_API_URL` to your API, such as `https://api.example.com/v1`. The CLI signs in and reads from there instead.
