Adding analytics to a site usually means leaving your editor: sign up, find the snippet, work out where your framework wants it, deploy, then come back to the dashboard to see if anything arrived. If you already have a coding agent open in the repository, it can do all of that for you.
Hark, a cookieless Google Analytics alternative, has an MCP server with tools for setting a site up as well as for reading its stats. Connect it once and you can ask your agent to add Hark to the project it's working on.
Connect Hark to Claude Code
Start a free trial (no card), create a key on the API keys page, then add the server:
claude mcp add --transport http hark https://harkstats.com/mcp --header "Authorization: Bearer YOUR_KEY"
Cursor, VS Code and other MCP clients work too; the setup instructions have the config for each. Claude and ChatGPT can connect without a key, by signing in.
Ask for it in plain English
In the repository for your site, ask something like:
Add Hark analytics to this site. The domain is example.com and we're in London.
The agent then works through the setup tools:
create_siteadds example.com to your account with the Europe/London timezone and returns its tracking snippet.get_install_instructionssays where the snippet goes for your framework. For a Next.js App Router project, that's the<head>ofapp/layout.tsx. There are guides for plain HTML, Next.js, Astro, WordPress, Webflow, Ghost, Phoenix and Vite (which covers React, Vue, Svelte and SvelteKit).- The agent edits the file. The snippet is one line:
<script defer data-domain="example.com" src="https://harkstats.com/js/script.js"></script>
- Once you've deployed and opened the site,
check_installconfirms events are arriving. If they aren't, it lists what to check: thatdata-domainmatches, that a cache isn't serving an old copy of the page, that an ad blocker isn't blocking the script, and that localhost visits only count withdata-local.
The script is under 1 KB, sets no cookies and needs no consent banner, so there's nothing else to add.
Goals, funnels and campaign links
The same conversation can go further. Ask the agent to track a signup and it can add a custom event where your form succeeds:
window.analytics?.("Signup", { props: { plan: "pro" } })
Then:
save_funnelsaves a funnel such as "pricing page, then signup" on your dashboard.create_campaign_linkbuilds a link withutm_source,utm_mediumandutm_campaignfor your newsletter or a post, and keeps it with the site so its visits are easy to find.update_sitechanges the timezone, or counts a staging domain's events alongside the main one.
And when there's some traffic, ask about it: "Where did yesterday's visitors come from?" uses the same server's stats tools.
What it can't do
The tools that change things say so in their descriptions, so your client can ask before using them. None of them deletes anything, makes a dashboard public or touches billing: those stay on the dashboard, where you can see what you're doing.
The MCP server is on every plan, including the $5 Starter plan and the free trial. Try it on your own site.