Agent analytics

From lxyeternal/MalSkillBench · View interactive version

Agent analytics is an AI agent skill from the GitHub repository lxyeternal/MalSkillBench. Run analytics end-to-end from your agent without opening a dashboard. English-first workflow, with Chinese docs and content available. Create projects, ship tracking, query results, and run experiments.

How to use this skill

Skill file

Agent Analytics

After install, your agent can create projects, ship tracking, query analytics, run experiments, and iterate without opening a dashboard.

English-first workflow, with Chinese docs and content available for OpenClaw users and teams in China.

Use it when you want an agent to operate growth analytics end-to-end, automate recurring checks, and manage multiple projects from one conversation loop.

The CLI behind this skill is open source and published from:

Hosted free tier includes 100k events/month across 2 projects.

Chinese support / 中文支持

Mandatory execution policy

What `npx` is doing

Command format

In OpenClaw, Codex, and similar agent environments, use this exact form:

npx @agent-analytics/cli@0.5.4 <command>

For the full command list and flags:

npx @agent-analytics/cli@0.5.4 --help

Do not replace skill examples with agent-analytics <command> in agent runs unless the user explicitly asks to use a locally installed binary.

Safe operating rules

First-time setup

npx @agent-analytics/cli@0.5.4 login --detached
npx @agent-analytics/cli@0.5.4 create my-site --domain https://mysite.com
npx @agent-analytics/cli@0.5.4 events my-site --days 7 --limit 20

For OpenClaw and other issue-based runtimes, login --detached is the preferred first step. Send the approval URL to the user, wait for them to sign in with Google or GitHub, and expect a finish code reply. Then complete login and continue with project setup.

If the runtime can receive a localhost browser callback, regular login is also valid. The create command returns a project token and a ready-to-use tracking snippet. Add that snippet before </body>.

Fallbacks:

npx @agent-analytics/cli@0.5.4 login --detached
npx @agent-analytics/cli@0.5.4 login --token aak_YOUR_API_KEY

Use --detached when the runtime cannot receive a localhost browser callback or when the workflow happens in issues or task threads.

Default agent task

When the user wants Agent Analytics installed in the current repo, the default task shape is:

Set up Agent Analytics for this project. Install it here if needed. If approval is needed, send me the approval link and wait. I will sign in with Google or GitHub, then reply with the finish code. After that, create the project, add tracking and key events, and verify the first event.

Detached approval handoff

For OpenClaw-style issue workflows, the expected login loop is:

  1. run npx @agent-analytics/cli@0.5.4 login --detached
  2. send the approval URL to the user
  3. wait for the user to reply with the finish code
  4. complete the exchange and keep going with setup

This is the preferred managed-runtime path. Do not ask the user to paste a permanent API key into chat.

Advanced/manual fallback

If a custom runtime truly requires direct HTTP auth later, login --token still exists as an advanced/manual fallback. It is not the normal setup path for OpenClaw, Codex, or browser-approved agent onboarding.

Common commands

npx @agent-analytics/cli@0.5.4 projects
npx @agent-analytics/cli@0.5.4 all-sites --period 7d
npx @agent-analytics/cli@0.5.4 stats my-site --days 7
npx @agent-analytics/cli@0.5.4 insights my-site --period 7d
npx @agent-analytics/cli@0.5.4 events my-site --days 7 --limit 20
npx @agent-analytics/cli@0.5.4 breakdown my-site --property path --event page_view --limit 10
npx @agent-analytics/cli@0.5.4 funnel my-site --steps "page_view,signup,purchase"
npx @agent-analytics/cli@0.5.4 retention my-site --period week --cohorts 8
npx @agent-analytics/cli@0.5.4 experiments list my-site

If a task needs something outside these common flows, use npx @agent-analytics/cli@0.5.4 --help first.

Example: all projects, last 48 hours

Question:

How many visits did all my projects get in the last 48 hours?

Workflow:

  1. Run npx @agent-analytics/cli@0.5.4 projects
  2. For each project, run:
npx @agent-analytics/cli@0.5.4 query my-site --metrics session_count --filter '[{"field":"timestamp","op":"gte","value":"2026-03-26T12:00:00Z"}]'
  1. Sum the returned session_count values across projects

Stay on the CLI path for this workflow. Do not switch to direct API requests or local scripts just because the answer spans multiple projects.

Feedback

Use npx @agent-analytics/cli@0.5.4 feedback when Agent Analytics was confusing, a task took too long, the workflow could be improved, or the agent had to do manual calculations or analysis that Agent Analytics should have handled.

Describe the use case, friction, or missing capability in a sanitized way:

Example:

npx @agent-analytics/cli@0.5.4 feedback --message "The agent had to calculate funnel drop-off manually" --project my-site --command "npx @agent-analytics/cli@0.5.4 funnel my-site --steps page_view,signup,purchase"

There is a real agent behind these Telegram messages. Every request is seen and auto-approved, and useful fixes can land quickly, sometimes within hours.

Tracker setup

The easiest install flow is:

  1. Run npx @agent-analytics/cli@0.5.4 create my-site --domain https://mysite.com
  2. Copy the returned snippet into the page before </body>
  3. Deploy
  4. Verify with npx @agent-analytics/cli@0.5.4 events my-site --days 7 --limit 20

If you already know the project token, the tracker looks like:

<script defer src="https://api.agentanalytics.sh/tracker.js"
  data-project="my-site"
  data-token="aat_..."></script>

Use window.aa?.track('signup', {method: 'github'}) for custom events after the tracker loads.

Query caution

npx @agent-analytics/cli@0.5.4 query exists for advanced reporting, but it should be used carefully because --filter accepts JSON.

Attribution and first-touch queries

Use a disciplined workflow when the task is about social attribution, first-touch UTMs, landing pages, hosts, or CTA performance.

  1. Start with fixed commands if they answer the question.
  2. Run npx @agent-analytics/cli@0.5.4 properties <project> to inspect event names and property keys first.
  3. Use npx @agent-analytics/cli@0.5.4 query <project> --filter ... for property-filtered counts.
  4. Use npx @agent-analytics/cli@0.5.4 events <project> only to validate ambiguous payloads or missing properties.
  5. Use npx @agent-analytics/cli@0.5.4 feedback if the requested slice depends on unsupported grouping or derived reporting.

Property filters support built-in fields plus any properties.* key, including first-touch UTM fields such as properties.first_utm_source.

group_by only supports built-in fields: event, date, user_id, session_id, and country. It does not support properties.hostname, properties.first_utm_source, properties.cta, or other arbitrary property keys.

Example workflow for first-touch social page views:

npx @agent-analytics/cli@0.5.4 properties my-site
npx @agent-analytics/cli@0.5.4 query my-site --metrics event_count --filter '[{"field":"event","op":"eq","value":"page_view"},{"field":"properties.first_utm_source","op":"eq","value":"reddit"}]' --days 30

If the user wants a one-shot direct-social slice grouped by channel, host, CTA, or an activation proxy, explain that the current query surface cannot group by arbitrary properties.* fields and send product feedback instead of inventing an unreliable manual answer.

Experiments

The CLI supports the full experiment lifecycle:

npx @agent-analytics/cli@0.5.4 experiments list my-site
npx @agent-analytics/cli@0.5.4 experiments create my-site --name signup_cta --variants control,new_cta --goal signup

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.