Victor Li

Setting up Web Analytics

When it came to setting up web analytics for my website, I ended using Umami.

You can view my site’s public analytics here: iamvictorli.com analytics

Why Umami:

My Integration Code

Here’s how I integrated Umami. The snippet dynamically loads the analytics script only in production mode:

---
const isProd = import.meta.env.PROD
---

{
  isProd ? (
    <script is:inline src="https://cloud.umami.is/script.js" data-website-id="b6fcbcca-55fc-44da-94b3-f160f56023ae" />
  ) : null
}

Code in my project’s repo

Self-Hosting: A Flexible Alternative

Both Umami and Plausible support self-hosting, which can be a great option if you want:

Self-Hosting Resources for Umami:

Self-Hosting Resources for Plausible:

List of great analytics with Astro: https://github.com/Destiner/astro-analytics