I want to use vercel analytics in astro but I'd have to create a library for that I see that you have a nice set of Components that Allow the user to integrate analytics from other sites. I'm going to just give you the code for how to integrate Vercel Analytics if you want more info look into the docs.
You need to install web-vitals in order to use the code below.
<script>
// Replace this with the one that comes from the file with the script that I have written above.
import { webVitals } from "~/utils/vitals";
const analyticsId = import.meta.env.PUBLIC_VERCEL_ANALYTICS_ID;
if (analyticsId) {
webVitals({
analyticsId,
path: location.pathname,
params: location.search,
debug: !import.meta.env.PROD,
});
}</script>
I want to use vercel analytics in astro but I'd have to create a library for that I see that you have a nice set of Components that Allow the user to integrate analytics from other sites. I'm going to just give you the code for how to integrate Vercel Analytics if you want more info look into the docs.
You need to install
web-vitals
in order to use the code below.Code needed for Web Analytics
Astro Component