Analytics for builders
Install the tracker with an agent and read a test page view back through the CLI
By Theo Marsh · Nov 26, 2026 · 8 min read
The finish line is a read, not a file edit
Many sites have no traffic tool at all. W3Techs reports that 43% of the websites it checks use none of the traffic analysis tools it monitors, and that Google Analytics is on 46.1% of them. The shares overlap, because a site can run more than one tool, and they cover only the tools W3Techs monitors. The figures were listed on Nov 23, 2026.
Source: W3Techs, Usage statistics and market share of traffic analysis tools for websites, Nov 23, 2026. Retrieved Nov 23, 2026.
A tag that is installed but never reports leaves you in the same place as the 43%. An agent can edit a template and say "done" while the page that visitors load is an older build, or while the key in the tag is still a placeholder. Each step from file edit to stored row can fail without an error message. So the last step of the prompt should be a read of the data, run by the agent, in the same shell where it made the edit.
This post builds that prompt around the command line instead of MCP. The command line needs no install, and it speaks the same MCP endpoint an agent does, so a command and a tool call return the same numbers. If your agent already has MCP connected, the MCP version of this check is the shorter route. If it does not, this one needs no client configuration.
The one step you do by hand
You create an API key on your Peeko settings page. Everything else in the session is the agent's job. Export the key in the shell the agent will run in:
export PEEKO_API_KEY="paste_your_key_here"
npx @usepeeko/cli whoami
With the variable set, the commands read it and write nothing to disk. The one exception is peeko use, which still stores a default site. whoami shows the key in use, how many sites it reaches and the default site. Keep the key out of the prompt text and out of any file the agent might commit. It reads your traffic, so treat it like a password.
If the site does not exist yet, create it from the same shell:
npx @usepeeko/cli init --name "Example site" --domain example.com
init creates a site and prints its snippet and an agent prompt, with your real site key filled in. Run npx @usepeeko/cli init --help for the options. The site key goes in the page. The API key does not.
The trial is fourteen days with no card, and it covers one site, so a first install costs nothing to try.
The prompt
Paste this into your agent, then replace SITE_KEY and DOMAIN in the first line. The commands inside are written out in full so the agent can run them as they are.
Add Peeko analytics to this project and prove it is receiving data.
SITE_KEY=your_site_key DOMAIN=example.com
Work in the shell only. PEEKO_API_KEY is already set. Never print it
and never write it to a file.
1. Run: npx @usepeeko/cli whoami
Exit code 2 means the key is missing or rejected. Stop and report
NOT PROVEN, step 1.
2. Add this tag inside <head> on every page, using the real SITE_KEY:
<script defer src="https://usepeeko.com/t.js" data-site="SITE_KEY"></script>
3. Deploy with this project's normal deploy command. If you cannot
deploy, stop and report NOT PROVEN, step 3.
4. Fetch the live page and look for the tag:
curl -s https://DOMAIN/ | grep -o '<script[^>]*usepeeko.com/t.js[^>]*>'
The tag must appear and must not contain YOUR_SITE_KEY.
Otherwise stop and report NOT PROVEN, step 4.
5. Send a test page view to a path nobody else uses:
TEST_PATH=/peeko-check-$(date +%s)
curl -sS -o /dev/null -w "%{http_code}\n" -X POST "https://usepeeko.com/a" -H "content-type: application/json" -H "Origin: https://DOMAIN" --data '{"k":"SITE_KEY","p":"'"$TEST_PATH"'","r":"https://DOMAIN/","sw":390,"sh":844,"vw":390,"vh":844,"cs":"dark"}'
Anything other than 204: stop and report NOT PROVEN, step 5.
A 204 alone is never PROVEN.
6. Read it back, at most 6 tries, 10 seconds apart:
OUT=$(npx @usepeeko/cli pages --site DOMAIN --range 24h --filter page="$TEST_PATH" --limit 100 --json); CODE=$?
- CODE 0 and OUT contains TEST_PATH: report PROVEN.
- CODE 0 and OUT lacks TEST_PATH: wait 10 seconds and try again.
- CODE 2: wait 10 seconds and try again.
- CODE 1: stop. Retrying will fail the same way.
After 6 tries, report NOT PROVEN, step 6.
7. End with one line only:
PROVEN: <TEST_PATH> read back from DOMAIN
or NOT PROVEN, step N: <reason>
Three choices in that prompt are worth explaining.
The test path is made up and unique. A timestamp in the path means the agent can only pass by reading its own beacon, not a real visit that happened to land earlier. It also keeps the proof from depending on traffic you do not control.
The read uses --filter page=. The pages command returns at most 100 rows, ranked by views, and a path with one view can fall below that cutoff on a busy site. The docs do not say whether the filter matches a path exactly or by prefix, but a timestamped path works under either reading.
The referrer is your own domain. The beacon example in the Peeko docs uses a Hacker News referrer. The prompt swaps in your domain so the test row does not pose as a visit from Hacker News.
The Origin header is there on purpose. The docs' example does not show one, but our own first-page-view troubleshooting post says Peeko refuses a beacon whose Origin is not the one your site would send, and logs a rejected request on your install card. Sending your domain removes that failure from the test.
What each step proves and what it leaves open
| Step | Passes when | It proves | It leaves open |
|---|---|---|---|
1. whoami | Exit code 0 | The key is accepted and reaches the site | Whether the site key in the tag is right |
| 4. Live HTML | Tag found, no placeholder | The deployed page carries the tag | Whether a browser runs it |
| 5. Beacon | HTTP 204 | The request reached Peeko in a well formed shape | Anything about the key |
| 6. Read-back | Test path in output | A row was stored under that site and the key can read it | Whether the tag fires in a real browser |
The 204 row matters most. The ingest endpoint answers 204 to every well formed beacon, valid key or not, so a tracker can never leak whether a key is real. That is a good property for privacy and a bad one for testing, because a typo in the key gets the same answer as a correct key. Only the read-back, which finds the path under the site you named, ties the key, the endpoint and the read path together.
Exit codes are the agent's branching logic
The CLI documents three exit codes. Using them directly means the agent does not have to interpret error text.
- 0 means success. In step 6 it still has to find the path in the output, because a successful read with no match is a normal result while the row is not there yet.
- 1 means the command ran and failed. Retrying unchanged will fail again, so the prompt stops.
- 2 means the command could not run: a rejected key, a rate limit or no network. Retrying may help. A missing key and a rejected key both return 2, which is why step 1 treats a 2 as a stop. Once
whoamihas passed, a 2 in step 6 is far more likely to be the network or a rate limit than the key, so the prompt retries.
The docs say a visit shows up on the dashboard within a few seconds, but they give no exact figure for how long a stored row takes to become readable, so this post does not state one. The prompt polls six times, ten seconds apart, and then fails with a reason. A bounded loop is the honest way to handle a delay you cannot name. It also keeps an agent from waiting forever or declaring success on a guess. If the verdict is NOT PROVEN at step 6 on a site where steps 4 and 5 passed, work through the ranked causes of a missing first page view, starting with a key that differs between the tag and the beacon.
Keep the proof visit out of your own tagging
Do not use ?me=1 to make the proof visit. Opening your site with ?me=1 tags your browser as yours. Tagged visits show a "You" badge and are excluded from every number unless you turn on "Count my own visits" in site settings. A proof built on a tagged visit would show nothing, and you would read that as a failed install. The curl beacon in step 5 carries no such tag. For the longer picture of keeping your own browsing out of the totals, see how to keep your own visits out of your site analytics.
The test beacon leaves one row behind, a single view of /peeko-check- plus a number. It sits in your page list under that name. Because page views are kept three years by default, name it so you can recognize it later.
What this check does not cover
A curl beacon proves the endpoint and the read path. It does not prove that a visitor's browser executes the script. A content security policy, a consent banner or a tag manager can still block it. To close that gap, load your site normally in a browser, without ?me=1, and run the same pages command for the real path.
If you would rather check the live page from outside the agent, the free analytics checker takes any page and shows which of 18 analytics tools it loads, with no signup.
This check also leaves out three other things:
- AI crawler hits. Crawlers do not run JavaScript, so they are counted on a separate server side path, the
@usepeeko/bot-trackmiddleware. A browser tag cannot see them. Installing the tag does not install that. - Visits from AI assistants. Visits from ChatGPT, Claude, Perplexity, Copilot and Gemini are counted from ordinary page views by their referrer, with no middleware. Seeing them depends on real traffic, not a test beacon.
- Goals, funnels and revenue. A goal is a definition rather than a counter, so you can write one after the tag is live and it counts earlier visits. None of that needs to be part of the first proof.
Nobody has published a success rate for agents running this exact prompt, and this post reports none. What it gives you is a pass condition that an agent cannot meet by editing a file. When the agent is done, it should hand you either a path read back from your own site or the step where it stopped.
If you later want the agent to answer traffic questions as well as prove an install, connect Claude Code or Cursor over MCP. For reading the same numbers yourself, the CLI guide for the terminal lists the commands.