How to enable analytics on Vercel
Log into Vercel Dashboard, select your project, enable Analytics in the sidebar, install <code>@vercel/analytics</code>, add the framework-specific <code><Analytics /></code> component to your root layout, and redeploy. Data appears in the Analytics tab after ~1 hour of traffic, but dashboard enable alone only provides server-side data—client-side requires code integration.
Prerequisites
- A deployed project on Vercel (Next.js, Remix, Nuxt, SvelteKit, Astro, or similar)
- Vercel account with dashboard access to the project
- Node.js project with npm/yarn/pnpm for package installation
- Basic knowledge of your framework's root layout or app file
- Familiarity with deploying code changes to Vercel
Step-by-Step Instructions
Log in to Vercel Dashboard
vercel.com/dashboard and select the specific project where you want to enable Web Analytics. Ensure you have access to a deployed project.Access Analytics Section
Enable Web Analytics
/_vercel/insights/* and //* for data collection, which take effect after your next deployment. No code changes are needed for basic server-side setup.Install @vercel/analytics Package
npm install @vercel/analytics (or use yarn/pnpm). This installs the latest version by default and enables client-side tracking like page views and events when integrated.Integrate for Next.js App Router
app/layout.tsx), import and add the component before </body>: import { Analytics } from '@vercel/analytics/next';
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>{children}</body>
<Analytics />
</html>
);
} Mode defaults to 'production' in builds.Integrate for Next.js Pages Router
_app.js or pages/_app.tsx: import { Analytics } from '@vercel/analytics/next';
function MyApp({ Component, pageProps }) {
return (
<>
<Component {...pageProps} />
<Analytics />
</>
);
}Integrate for Other Frameworks
<Analytics /> before <Outlet /> in App root. For Nuxt, add modules: ['@vercel/analytics'] in nuxt.config.ts. For SvelteKit, use injectAnalytics({ mode: dev ? 'development' : 'production' }) in +layout.js. For Astro (serverless), configure in astro.config.mjs with webAnalytics: { enabled: true }.Deploy Your Changes
View Analytics Data
Common Issues & Troubleshooting
No data appearing in Analytics tab after Enable
Dashboard enable only adds server routes; install <code>@vercel/analytics</code>, add <code><Analytics /></code> to root layout, redeploy, and wait ~1hr for client-side data.
Module not found: Can't resolve '@vercel/analytics'
Run <code>npm i @vercel/analytics</code> in project root and ensure correct framework import (e.g., <code>@vercel/analytics/next</code>).
Analytics not tracking in development
Set <code>mode: 'development'</code> where supported (e.g., SvelteKit), or test in production deploy. Local dev may not send data.
Component errors like hydration mismatch
Place <code><Analytics /></code> correctly inside <code><body></code> (Next.js App Router) or before Outlet/content root.
Data only shows server-side metrics
Client-side requires package install and <code><Analytics /></code> integration—dashboard enable alone is insufficient.