# CLI

SleekTrack is scriptable from the terminal. Every command lives under
`wp sleek track`, and the commands that read data take `--format=json`, which
makes them easy to use from deploy scripts, cron jobs and coding agents.
[WP-CLI commands](/docs/track/reference/cli.md) lists every command with its
arguments; `wp help sleek track <command>` prints the same on a site.

## What the commands cover

- Sites: `wp sleek track sites list`, `get`, `create`, `update`, `delete`,
  `script` and `self-register`. `wp sleek track sites create` prints only the
  new id with `--porcelain`, and `wp sleek track sites self-register` tracks
  the current install with the tracking code added automatically, like **Track
  this site**. `wp sleek track sites delete` also deletes the site's events
- Statistics: `wp sleek track stats`, `wp sleek track breakdown`,
  `wp sleek track realtime` and `wp sleek track events`, which lists raw
  events newest first
- Maintenance: `wp sleek track cleanup` runs the retention prune and the salt
  cleanup of the daily background task on demand, optionally with a one-off
  retention
- Networks: `wp sleek track network list`, `wp sleek track network enable`
  and `wp sleek track network disable`, available when SleekTrack is
  network-activated

## Example

```bash
wp sleek track sites create --domain=example.com --name=Example --porcelain
wp sleek track stats 1 --period=30d --format=json
wp sleek track breakdown 1 --property=source --limit=20 --period=custom --from=2026-09-01 --to=2026-09-30
```

## Periods and breakdowns

Periods match the dashboard: `day`, `7d`, `30d`, `month`, `6mo`, `12mo`,
`all`, or `custom` with `--from` and `--to` as `YYYY-MM-DD` dates. The
commands default to `7d`, where the dashboard opens on the last 30 days.

Breakdown properties match the dashboard's cards, such as `page`, `source`,
`country` or `goal`. On the command line, `goal` lists named events only;
pageview goals are reported by the dashboard. Bot filtering happens during
collection, so the commands and the dashboard read the same events. Filters
are a dashboard feature and have no command-line option.

## Sites on a network

Site commands run against the site that WP-CLI's global `--url` flag selects,
so this reads a network site's analytics:

```bash
wp --url=client-one.com sleek track stats 1
```

## The Track assistant

The Track assistant runs these same commands for you, in the site's own
process rather than a shell, and reads the listing and statistics commands as
JSON. Deleting a
site, running cleanup and disabling a network site ask an administrator to
confirm first, and the network commands need the `manage_network_options`
capability.
