Astro 3 / 4 / 5, Islands & View Transitions

Open-source web analytics and RUM for Astro

High-performance, cookieless analytics tailored for Astro's content-driven architecture. Full compatibility with Astro View Transitions, zero JS bloat, and automated Core Web Vitals.

Astro View Transitions SupportZero JavaScript Runtime BloatAstro is:inline DirectivesContent Collections TrackingCookieless Privacy CompliancePerfect 100 Lighthouse Scores
Quick Installation
Add deferred script to src/layouts/Layout.astro

Complete Astro Integration Guide

Follow these steps to track pageviews, custom events, Core Web Vitals, and errors.

1Add Script to Base Layout Component

Use the `is:inline` directive in your primary `Layout.astro` file to prevent Astro from bundling or renaming the external analytics script.

src/layouts/Layout.astro
<!-- src/layouts/Layout.astro -->
<script
  is:inline
  defer
  src="https://api.openanalytics.org.in/open.js"
  data-project-id="prj_your_project_id"
></script>

2Supporting Astro View Transitions

If your Astro application uses `<ViewTransitions />`, listen to `astro:page-load` to ensure smooth client-side transition reporting.

src/components/AnalyticsWatcher.astro
<!-- src/components/AnalyticsWatcher.astro -->
<script>
  document.addEventListener("astro:page-load", () => {
    if (window.OpenAnalytics) {
      window.OpenAnalytics.page(window.location.pathname);
    }
  });
</script>

3Client Island Custom Events

Dispatch custom business conversions from within interactive React, Vue, or Svelte client islands.

src/components/Newsletter.tsx
export default function Newsletter() {
  const handleSubmit = (e: React.FormEvent) => {
    e.preventDefault();
    if (window.OpenAnalytics) {
      window.OpenAnalytics.track("newsletter_submitted", {
        form_location: "blog_sidebar",
      });
    }
  };
  return <form onSubmit={handleSubmit}><button type="submit">Subscribe</button></form>;
}
Custom Events & Conversions

Tracking Astro Content Reading & Downloads

Capture documentation reading completions and code copy events.

document.querySelectorAll("[data-copy-button]").forEach((btn) => {
  btn.addEventListener("click", () => {
    if (window.OpenAnalytics) {
      window.OpenAnalytics.track("code_snippet_copied", {
        code_language: btn.getAttribute("data-lang") || "bash",
        page: window.location.pathname,
      });
    }
  });
});
Core Web Vitals RUM

Automated Field Performance

Astro websites emphasize pristine performance. Open Analytics complements Astro by executing in under 2ms with less than 3.2KB payload, helping you maintain perfect 100 Google PageSpeed scores.

Error Observability

Runtime Crash Triage

Captures runtime errors arising inside interactive client islands or global layout scripts, linking crashes to specific rendered markdown posts or dynamic routes.

Developer Questions

Frequently Asked Questions

Add Open Analytics to your Astro app today

Zero cookies, sub-3.2 KB payload, real-time Core Web Vitals RUM, and automated crash triage.