Let an AI coding agent install Crustat
Copy a ready-made prompt with your own tracking line in it, paste it into your AI coding agent, and check the one file it changed.
When this helps
If you build your site with an AI coding agent, like Claude Code, Cursor or GitHub Copilot, you can hand it the install. Crustat writes the instructions for you, with your real tracking line already in them, so the agent knows exactly what to add and where.
Get the prompt
- In Crustat, open your site and go to Site settings → Install.
- Under Where does your domain run?, pick the AI agent tab.
- Click Copy the prompt. To read it first, click See the prompt.
The same prompt also appears on your site’s stats page while it’s waiting for its first visit.
What the prompt asks for
The prompt is in English in every language of the app, since agents follow English instructions best. It gives the agent your exact line and these rules:
- Once, in the shared layout. Add the line in the template that renders
<head>for every page, likeindex.html, a root layout, a base template or the theme header. Not page by page. - Exactly as it is. Don’t change the
srcor thedata-sitevalue, and keepdefer. - A plain script tag is simplest. A framework’s own script component, like the one in Next.js, works too, as long as it keeps the same
srcanddata-site. - No duplicates. If there’s already a Crustat line, replace it instead of adding a second one.
- Rocket Loader and script combiners. If the site uses Cloudflare Rocket Loader, or a plugin that combines or delays scripts, add
data-cfasync="false"or exclude the line from that plugin. - Content-Security-Policy. If the site sets one, allow
https://stats.crustat.cominscript-srcandconnect-src.
It ends by asking the agent to tell you which file it changed and to show you the line as it ended up.
Use it
- Open your project in your agent.
- Paste the prompt and send it.
- Read the agent’s answer. Check the file it names and the line it shows. The
data-sitevalue should match the Site ID on your Install page. - Publish the change the way you usually do.
Check that it worked
Open your live site, not localhost, and wait about a minute. On Site settings → Install the badge changes from No visits yet to Working since and the day.
If it doesn’t change, ask the agent to show you where the line ended up in the built page, or check it yourself: view the page source of your live site and search for crustat. Then see visits aren’t showing up.
Using a framework?
For Astro and Next.js there are also ready-made packages. You can point your agent at them instead: Astro, Next.js. Either way works.
Still stuck? Write to hello@crustat.com.