Add agentlytics to your site
One script tag, under 1 KB, no cookies. About two minutes on most platforms.
The fastest way: ask your coding agent
Add agentlytics analytics to this project. Follow the instructions at measuremy.site/llms.txtYour agent reads /llms.txt, asks for your email and domain, signs you in with a 6-digit code we email you, adds the snippet to your project's layout, tracks your signups and connects itself over MCP. The steps below do the same by hand.
1. Get your snippet
Create a free account, add your domain, and copy the snippet from your site's Setup tab. It looks like this:
<script defer src="https://a.measuremy.site/t.js" data-key="YOUR_SITE_KEY"></script>
- Put it inside
<head>on every page you want counted. - The key is public and can only record visits, so it's safe in page source.
- One site covers its subdomains:
example.comalso countswww.example.comandblog.example.com. Visits from other hosts, includinglocalhost, are rejected.
2. Add it to your platform
Plain HTML
Paste the snippet inside <head> on every page, or in the shared header template if your pages use one.
Next.js
App Router: add it to the <head> in app/layout.tsx:
export default function RootLayout({ children }) {
return (
<html lang="en">
<head>
<script defer src="https://a.measuremy.site/t.js" data-key="YOUR_SITE_KEY"></script>
</head>
<body>{children}</body>
</html>
);
}
Pages Router: put the same tag inside <Head> in pages/_document.tsx. Client-side route changes are tracked automatically.
React, Vue, Svelte (Vite and other SPAs)
Add the snippet to index.html inside <head>. Route changes made with the History API (React Router, Vue Router, SvelteKit and most others) are counted as pageviews automatically.
Astro, Hugo, Jekyll, Eleventy
Add the snippet to the base layout that renders <head> (for example src/layouts/Layout.astro, layouts/partials/head.html or _includes/head.html).
WordPress
Easiest: install a header-code plugin such as WPCode, choose Header, paste the snippet and save. Or, with a child theme, paste it just before </head> in header.php.
Webflow
Site settings → Custom code → Head code, paste the snippet, save, then publish the site. Custom code requires a paid site plan.
Framer
Site settings → General → Custom Code, paste into Start of <head> tag, then publish.
Shopify
Online Store → Themes → … → Edit code, open layout/theme.liquid and paste the snippet just before </head>. Save.
Squarespace
Settings → Advanced → Code Injection → Header, paste and save. Code injection needs a Core plan or higher.
Wix
Settings → Custom Code → Add Custom Code, paste the snippet, choose All pages and Head, apply. Requires a premium plan with a connected domain.
Ghost
Settings → Code injection → Site header, paste and save.
Google Tag Manager
Prefer pasting the snippet directly. If you must use GTM, create a Custom HTML tag with the snippet, fire it on All Pages, and publish the container. Ad blockers that block GTM will also block it. Because the snippet isn't in your page's HTML, verify your domain with the DNS TXT record on the Setup tab.
3. Track conversions
Pageviews are automatic. To learn which channels bring customers, record the moments that matter with agentlytics.track(name, props):
// after a successful signup
agentlytics.track("signup", { plan: "free" });
// a purchase or upgrade
agentlytics.track("purchase", { plan: "pro", value: 29 });
// a button click
document.querySelector("#book-demo").addEventListener("click", () => agentlytics.track("demo_request"));
- Any custom event counts as a conversion for the channel the visitor arrived from (same day).
- Names up to 100 characters; props are optional, up to 2 KB of JSON. Don't put personal data (emails, names) in props.
- The script loads with
defer. If you calltrackvery early, guard it:window.agentlytics && agentlytics.track("signup").
4. Use campaign links
Links with UTM tags are attributed to that campaign. Create them on your site's Campaigns tab, or ask your agent to call create_tracked_link. Either way the campaign is logged so spikes and conversions are credited to it.
https://example.com/pricing?utm_source=newsletter&utm_medium=email&utm_campaign=october-launch
5. Check it works
- Open your site in a normal browser window (not one with an ad blocker that blocks analytics).
- The first visit verifies that you own the domain: we fetch your homepage and look for your site key. Nothing is recorded until then. If the snippet isn't in your homepage's HTML (for example, it's added through Google Tag Manager), add the DNS TXT record shown on your site's Setup tab instead.
- Open your site's Overview in the dashboard and pick 24h. The visit appears within seconds.
- Spikes and AI explanations are computed hourly and need a few days of history to compare against.
Troubleshooting
| "Not verified" on your site | The snippet must be in the HTML your homepage returns, or the TXT record must be set. Use Check now on the Setup tab; we also re-check hourly. |
| No visits showing | Check the page source contains the snippet, and that the page's domain matches the site you added (or is a subdomain of it). |
| Content Security Policy errors | Add https://a.measuremy.site to both script-src and connect-src. |
| Fewer visits than expected | Some ad blockers block analytics scripts; bots and crawlers are filtered out on purpose. |
| Visits stopped | The free plan records 5,000 pageviews a month. Your dashboard shows usage; upgrade or wait for the next month. |