2023-12-18

Only 3 steps to enable vercel analytics on your astro

Table of Contents

1. Install @vercel/analytics


pnpm i @vercel/analytics

2. Enable analytics in your astro.config.mjs.

Enable analytics in your astro.config.mjs below. Just add “webAnanlytics” object to versel() as an argument.

https://vercel.com/docs/analytics/quickstart#enable-analytics-in-your-astro.config.mjs-file


import { defineConfig } from 'astro/config';
import vercel from '@astrojs/vercel/serverless';
 
export default defineConfig({
  output: 'server',
  adapter: vercel({
    webAnalytics: {
      enabled: true,
    },
  }),
});

You can enable it even if your “output” setting is “static”;

3. Deploy as production


vercel --prod

That’s all.