Install on Astro

Add XPmetric to your Astro base layout head so it loads on every route.

Astro sites should add the tracker in a base layout <head>, not inside a page component.

Replace YOUR_SITE_TOKEN with your site token from Settings → Sites → Get Script.

Tracking snippet

<script defer data-site="YOUR_SITE_TOKEN" src="https://xpmetric.com/p.js"></script>

Base layout

In src/layouts/BaseLayout.astro (or your root layout):

---
// frontmatter
---
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <script defer data-site="YOUR_SITE_TOKEN" src="https://xpmetric.com/p.js"></script>
    <slot name="head" />
  </head>
  <body>
    <slot />
  </body>
</html>

Replace YOUR_SITE_TOKEN with your token from the dashboard.

Why the layout?

Astro page components may not share a single <head>. Putting the script in the layout guarantees every route loads the tracker once.

Verify

Run npm run dev, visit two different routes, and confirm both pageviews appear in XPmetric.