Source: https://measuremy.site/guides/add-analytics-to-docusaurus

[measuremy.site](https://measuremy.site/) / [Guides](https://measuremy.site/guides)

# How to add analytics to your Docusaurus site

This adds measuremy.site, cookieless website analytics, to a Docusaurus site. It is one script tag of under 1 KB: no cookies, no npm package, no consent banner for the tracker. Every plan starts with a 30-day free trial, no card.

## The quickest way: ask your coding agent

Paste this into Claude Code, Cursor or Codex

`Add measuremy.site analytics to this project: connect the measuremy.site MCP server at https://a.measuremy.site/mcp for all my projects (claude mcp add --scope user; it signs in with OAuth, no key, and one sign-in covers every site), then tell me how to sign in. Details: measuremy.site/llms.txt`

The agent connects to measuremy.site, you sign in through your browser, and it adds the tag below to the right file for you. To do it by hand, follow the steps.

## 1. Get your site key

[Start a free trial](https://measuremy.site/login) and add your domain. The **Setup** tab shows your snippet with your site key filled in. The key is public and can only record visits, so it is safe in your source code.

## 2. Add the script tag

The quickest way is the plugin, which adds the tag to every built page (and leaves it out of `docusaurus start`):

```
npm install docusaurus-plugin-measuremysite
```

Then add it to `docusaurus.config.js` (or `.ts`) with your site's key:

```
export default {
  // ...
  plugins: [["measuremysite", { key: "pk_..." }]],
};
```

Or leave out `key` and set `MEASUREMYSITE_KEY` where `docusaurus build` runs. Either way every page gets this in its `<head>`:

```
<script defer src="https://a.measuremy.site/t.js" data-key="YOUR_SITE_KEY"></script>
```

Without the plugin, the config's `headTags` option adds the same tag: `headTags: [{ tagName: "script", attributes: { defer: true, src: "https://a.measuremy.site/t.js", "data-key": "pk_..." } }]`.

Moving between docs pages happens in the browser, without a full page load. Each one is still counted as a pageview, because the script listens for History API changes.

## 3. Check it works

Publish the change, then open your live site. The first visit from your own domain verifies it and the visit shows up on the dashboard within seconds. Visits from `localhost` aren't counted, so test on the deployed site.

## 4. Track signups and other conversions

In Markdown and MDX pages, add the attribute to a link or button: `<a href="/signup" data-measuremysite-event="signup_click">`. From a React component, `import { track } from "docusaurus-plugin-measuremysite"` and call `track("signup")` after a successful action.

Any event counts as a conversion for the channel the visitor came from.

For a docs site, the useful questions are which pages people read and where they came from. With the [MCP server](https://measuremy.site/docs/mcp) connected, ask your coding agent "which docs pages got the most visits this week, and from where?"

Other platforms, and funnels and campaign links, are in the [install guide](https://measuremy.site/docs/install).

### Try it on your site

30-day free trial, no card. Plans from $9/month. Paste one sentence into your coding agent, or add one script tag yourself.

[Start free trial](https://measuremy.site/login) [See the live demo](https://measuremy.site/share/measuremy.site)

Add measuremy.site analytics to this project: connect the measuremy.site MCP server at https://a.measuremy.site/mcp for all my projects (claude mcp add --scope user; it signs in with OAuth, no key, and one sign-in covers every site), then tell me how to sign in. Details: measuremy.site/llms.txt

## Free tools

- [Analytics tag checker](https://measuremy.site/tools/analytics-tag-checker): Which analytics and pixels a site runs, plus duplicate and broken tags.
- [HTTP status and redirect checker](https://measuremy.site/tools/http-status-checker): Status codes, redirect chains and headers for up to 25 URLs.
- [Free UTM link builder](https://measuremy.site/tools/utm-link-builder): Add utm_source, medium and campaign to any link.

[All free tools](https://measuremy.site/tools)

## More guides

- [A website analytics MCP server: ask your agent about your traffic](https://measuremy.site/guides/analytics-mcp-server)
- [Add website analytics to your project with Claude Code](https://measuremy.site/guides/claude-code-analytics)
- [Find out why your website traffic spiked](https://measuremy.site/guides/find-why-traffic-spiked)
- [Track clicks and find where visitors drop off, without writing code](https://measuremy.site/guides/funnels-and-click-tracking)
- [Cookieless analytics: how it works, and what you give up](https://measuremy.site/guides/cookieless-analytics)
- [A simpler Google Analytics alternative for developers](https://measuremy.site/guides/google-analytics-alternative)
- [How to add analytics to your Next.js site](https://measuremy.site/guides/add-analytics-to-nextjs)
- [How to add analytics to your Astro site](https://measuremy.site/guides/add-analytics-to-astro)
- [How to add analytics to your Vite, React or Vue site](https://measuremy.site/guides/add-analytics-to-vite-react)
- [How to add analytics to your SvelteKit site](https://measuremy.site/guides/add-analytics-to-sveltekit)
- [How to add analytics to your Hugo site](https://measuremy.site/guides/add-analytics-to-hugo)
- [How to add analytics to your WordPress site](https://measuremy.site/guides/add-analytics-to-wordpress)
