Analytics for builders
One agent prompt and two keys, one for your HTML and one that stays out of your repo
By Nora Blake · Nov 29, 2026 · 8 min read
Most install guides stop at "paste the tag." Proving the install worked means reading data back, and reading data needs a credential. Credentials are how agent sessions leak: a key pasted into a chat, a config file saved inside the project, a .env that gets committed. So the part of this job worth getting right is not the tag. It is which key goes where.
Two earlier posts cover the proof itself in more depth. Install the tracker with an agent and read a test page view back through the CLI walks through the read-back, and this one adds the credential rules and a check that the secret never shipped.
Two keys, two jobs
Peeko uses two different keys, and an agent session touches both.
| Site key | API key | |
|---|---|---|
| Where it lives | The data-site attribute in your HTML | An environment variable, never a file in the project |
| Who can see it | Anyone who views your page source | You and the agent session |
| What it does | Tells a beacon which site it belongs to | Lets the CLI or MCP server read your numbers, and create a site |
| Where you get it | The install card, or the output of init | The API keys card in your settings |
The site key is public by design, because the script tag carries it into every visitor's browser. Peeko's ingest endpoint answers 204 to every well formed beacon, valid key or not, so a stranger cannot use it to learn whether a key is real. The Peeko docs add that it answers 204 to a bad key, a disallowed origin and a bot alike, on purpose.
The API key is the one to protect. It is sent as a bearer token. Peeko's MCP server is read only except for one tool that creates a site, and it is scoped by construction to the sites of the teams you belong to. A leaked key therefore exposes your traffic numbers and lets someone create a site under your team, and the MCP endpoint offers nothing beyond that. That is a smaller blast radius than most credentials, but it is still your data, and a key pasted into a chat transcript should be treated as burned and replaced.
Check what the page already loads
Before an agent adds a counter, find out whether the site already has one. Agents that are told to "add analytics" will sometimes add a second tag next to an existing one, and the numbers then disagree for reasons nobody remembers.
The odds that a site already carries something are high. W3Techs, which tracks technology use across the web, reports that Google Analytics is used by 46.0% of all websites. It also reports that 43% of websites use none of the traffic analysis tools it monitors. That second number has a limit: it only counts the tools on W3Techs' own list, so a site it calls "none" may still run something it does not watch. Your own site is a coin flip between "nothing" and "something," and the install should not guess.
Source: W3Techs, Usage statistics and market share of traffic analysis tools for websites, November 2026, Nov 26, 2026. Retrieved Nov 26, 2026.
The free analytics checker takes any page and shows which of 18 analytics tools it loads, with no signup. It fetches the page once and reads the HTML your server sends back, so a tag injected later by JavaScript will not show in it. The prompt below tells the agent to leave any other analytics tag alone. Whether to remove an old one is your decision, not something to hand to an agent in the same session.
Hand over the secret without leaving it in the repo
There are four ways to give an agent the API key. They differ in where the key ends up.
An environment variable. Export it in the terminal before you start the agent, so the session inherits it:
export PEEKO_API_KEY=paste_your_key_here
The CLI reference says that with PEEKO_API_KEY set, no key is written to disk. If the agent is started from a different shell, it will not see the variable, and the first command in the prompt fails with exit code 2.
A stored login. npx @usepeeko/cli login prompts for the key and saves it to a config file readable only by you, at ~/.config/peeko/config.json unless XDG_CONFIG_HOME is set. That is outside your project, so a git add . cannot pick it up.
An MCP connection in Claude Code. The docs give one command, which puts the key in a header:
claude mcp add --transport http peeko https://usepeeko.com/api/mcp --header "Authorization: Bearer mcpk_your_key_here"
An MCP connection in Cursor. The docs show two places for the same JSON: ~/.cursor/mcp.json for all projects, or .cursor/mcp.json for one project. The second sits inside your repo. If you use it, the bearer token is in a file that git add . will stage. Use the home folder file, or add the project file to .gitignore before you paste the key. The longer setup is in Give Claude Code or Cursor read access to your site's traffic over MCP.
The prompt below uses the CLI because any agent with a shell can run it, and because npx @usepeeko/cli speaks the same MCP endpoint an agent does, so a command and a tool call return the same numbers. If your agent has the MCP connection instead, swap step 8 for the get_top_pages tool with a page filter on the test path.
The prompt
Paste this into the agent. Replace example.com with your domain and fill in SITE_KEY if the site already exists in Peeko. Leave it blank to have the agent create the site.
Install Peeko analytics on this site and prove that data arrives. Follow the
steps in order and stop at the first step that fails.
Rules for the whole session:
- The secret API key is in the environment variable PEEKO_API_KEY. Read it
from there only. Never print it, never write it to a file in this project,
and never save it inside a script. If any command output contains it, do
not repeat it.
- The site key is public and belongs in the HTML.
- Make no other change to the project: no packages, no cookie banner, and
leave any other analytics tag as it is.
- Each command may run in a fresh shell, so write literal values into later
commands instead of relying on shell variables.
Values: DOMAIN=example.com SITE_KEY=(blank if the site is not in Peeko yet)
1. Run: npx @usepeeko/cli whoami
If it exits with code 2, stop. The key is missing, rejected, or the
network is down.
2. If SITE_KEY is blank, run:
npx @usepeeko/cli init --name "Example" --domain example.com --json
and take the site key from the snippet it returns.
3. Add this to the head of every page, in the layout file the framework uses:
<script defer src="https://usepeeko.com/t.js" data-site="SITE_KEY"></script>
4. Deploy. If deploying needs the owner's approval, stop and say so.
5. Check the live page carries the tag with the right key:
curl -sS https://example.com/ | grep -c 'data-site="SITE_KEY"'
It must print 1 or more. If it prints 0, stop.
6. Check the secret did not ship:
git grep -qF --untracked -- "$PEEKO_API_KEY" && echo LEAK-IN-REPO
curl -sS https://example.com/ | grep -qF -- "$PEEKO_API_KEY" && echo LEAK-IN-PAGE
If either prints, stop.
7. Choose TEST_PATH as /peeko-check- followed by the output of date +%s.
Send one test beacon:
curl -sS -o /dev/null -w "%{http_code}\n" -X POST https://usepeeko.com/a \
-H "content-type: application/json" -H "Origin: https://example.com" \
--data "{\"k\":\"SITE_KEY\",\"p\":\"TEST_PATH\",\"r\":\"https://example.com/\",\"sw\":1512,\"sh\":982,\"vw\":1512,\"vh\":860,\"cs\":\"dark\"}"
Expect 204. Any other status came from something between this machine
and Peeko. Stop.
8. Read it back, up to 6 times, 10 seconds apart:
npx @usepeeko/cli pages --site example.com --range 24h --filter page="TEST_PATH" --limit 100 --json
Look for the exact TEST_PATH in the output. Exit code 2 means wait and
retry. Exit code 1 means stop.
9. End with exactly one line, either
PROVEN: TEST_PATH read back from Peeko
or
NOT PROVEN, step N: what you saw
A 204 or a tag in the HTML is not proof.
The count of six tries 10 seconds apart is our choice, not a documented limit. The Peeko docs say a visit shows up within a few seconds, so a full minute of polling is generous. The prompt asks the agent to look for the exact path rather than trust a non-empty result, because a filter can return neighbors you did not ask for.
We have not measured how often agents complete this prompt without help, and this post reports no success rate. The steps follow the documented behavior of the CLI and the ingest endpoint.
What the verdict can and cannot prove
Step 7 sends the beacon with curl, so it stands in for the script. A PROVEN line shows that your site key is real, the ingest endpoint accepted a beacon for it, and the read path returns it. It does not show that a visitor's browser runs t.js. Steps 3 and 5 cover most of that gap, since the tag is in the live HTML, but they do not execute it.
Close the gap with one real visit. Open the live site in a normal tab, and a visit shows up within a few seconds. Do not add ?me=1 to the URL for this check: that tags your browser as you, and tagged visits are left out of the numbers unless you turn on "Count my own visits" in site settings. How to keep your own visits out of your site analytics covers that setting.
Step 7 sends an Origin header because the docs warn that a request carrying your real key with no Origin header is one Peeko recognizes and then refuses, and it lands on your install card as a rejected request. Do not drop the header to shorten the command.
The test hit is a real page view on a made-up path, so it will sit in your pages list. The unique timestamp keeps it easy to spot.
If the verdict is NOT PROVEN
Match the step number to the cause:
- Step 1: Exit code 2 covers a missing key, a rejected key, a rate limit and no network. The CLI reference says a wrapper can retry on 2, which only helps with the last two. A missing key also exits with 2, so check that the agent was started from the shell where you exported it.
- Step 5 prints 0: The deploy has not published yet, or the tag went into a file that is not the shared layout. Wait a minute and fetch again, then look at which file the agent edited.
- Step 6 prints LEAK: Remove the key from the file, replace the key, and start the session again. The check searches tracked and untracked files but skips ignored ones, and it does not search git history or logs.
- Step 7 is not 204: The Peeko docs say any other status came from something between you and Peeko, such as a proxy or a firewall.
- Step 8 never finds the path: A 204 proves only that the request reached Peeko. A wrong site key also gets a 204, so compare the
data-sitevalue in your live HTML with the key on your install card.
Why your first page view is not showing up, ranked by likelihood goes further down this list.
What this session leaves out
The prompt proves the browser path only. AI crawlers do not run JavaScript, so they are counted by a separate server side path: the @usepeeko/bot-track middleware, which is ESM only, needs Node 20 or newer, has zero runtime dependencies and weighs under 3 KB gzipped. A page view you read back says nothing about whether that middleware is installed. How to see which AI crawlers reach a new site in its first 30 days covers that check.
The tag itself is one line, sets no cookie and needs no configuration once it is on the page. The 14-day trial needs no card and covers one site, so you can run this session on a real site before you decide anything else.