A

Beam for Astro

Beam aligns with Astro's lightweight philosophy: one script tag, no cookies, and no build-time dependency. Works with static, SSR, and hybrid rendering.

Get started free Explore live demo

No credit card required and setup in minutes

Install Beam on Astro

Replace YOUR_SITE_ID with your Beam site ID from the dashboard.

Add Beam to your base layout

---
// src/layouts/BaseLayout.astro
---
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width" />
    <slot name="head" />
  </head>
  <body>
    <slot />
    <script
      is:inline
      defer
      src="https://beam.keylightdigital.dev/js/beam.js"
      data-site-id="YOUR_SITE_ID">
    </script>
  </body>
</html>

Use is:inline so Astro does not transform the script and it is emitted exactly once per page.

Astro View Transitions setup

---
// src/layouts/BaseLayout.astro
import { ViewTransitions } from 'astro:transitions'
---
<html>
  <head>
    <ViewTransitions />
    <script
      is:inline
      defer
      src="https://beam.keylightdigital.dev/js/beam.js"
      data-site-id="YOUR_SITE_ID">
    </script>
  </head>
  <body><slot /></body>
</html>

Beam handles SPA-like transitions so route-level pageview coverage stays accurate without extra client hooks.

Verify your Astro integration

Use this checklist after publish so you know tracking is actually live in production.

  • Start or deploy your Astro site, then load two different URLs including a transition link if enabled.
  • Confirm Today range in Beam dashboard shows both paths.
  • Check Channels/Referrers to verify metadata collection beyond raw pageview count.

Why Beam works well for Astro

🍪

No consent UI needed

Astro sites focused on simplicity can keep privacy messaging clean with no analytics cookie banners.

Under 2KB, no build overhead

Beam is a plain script include with minimal runtime footprint and zero bundling cost.

🔄

View Transitions aware

Beam tracks route changes in Astro navigation flows so your dashboards do not undercount.

📊

Fast answers for content teams

See what pages, channels, and devices are performing without exporting data to ad platforms.

Ready to add Beam to Astro?

Start free, validate your first pageview, and then scale when traffic grows.

Related setup guides