Learn how to enable and integrate Vercel Web Analytics into your project to track visitors and page views.
Choose your package manager and run the appropriate command:
pnpm i vercelyarn add vercelnpm install vercelbun add vercel/_vercel/insights/*) after your next deployment.
Install the @vercel/analytics package using your package manager:
pnpm add @vercel/analyticsyarn add @vercel/analyticsnpm install @vercel/analyticsbun add @vercel/analyticsAdd the Analytics component to your main app file:
import type { AppProps } from "next/app";
import { Analytics } from "@vercel/analytics/next";
function MyApp({ Component, pageProps }: AppProps) {
return (
<>
<Component {...pageProps} />
<Analytics />
</>
);
}
export default MyApp;import { Analytics } from "@vercel/analytics/next";
function MyApp({ Component, pageProps }) {
return (
<>
<Component {...pageProps} />
<Analytics />
</>
);
}
export default MyApp;Add the Analytics component to your root layout:
import { Analytics } from "@vercel/analytics/next";
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<head>
<title>Next.js</title>
</head>
<body>
{children}
<Analytics />
</body>
</html>
);
}import { Analytics } from "@vercel/analytics/next";
export default function RootLayout({ children }) {
return (
<html lang="en">
<head>
<title>Next.js</title>
</head>
<body>
{children}
<Analytics />
</body>
</html>
);
}Add the Analytics component to your main App component:
import { Analytics } from "@vercel/analytics/react";
export default function App() {
return (
<div>
{/* ... */}
<Analytics />
</div>
);
}import { Analytics } from "@vercel/analytics/react";
export default function App() {
return (
<div>
{/* ... */}
<Analytics />
</div>
);
}For static HTML sites, add the following script tag to your HTML files:
<script>
window.va = window.va || function () { (window.vaq = window.vaq || []).push(arguments); };
</script>
<script defer src="/_vercel/insights/script.js"></script>@vercel/analytics package. However, there is no route support. Once your site is deployed, the script will automatically track visitors and page views.
Add the Analytics component to your main App component:
<script setup lang="ts">
import { Analytics } from '@vercel/analytics/vue';
</script>
<template>
<Analytics />
<!-- your content -->
</template>vue-router.
Import and call the inject function in your main app file:
import { inject } from "@vercel/analytics";
inject();inject function should only be called once in your app and must run in the client. There is no route support with this method.
Deploy your app using the Vercel CLI:
vercel deployIf you haven't already, we recommend connecting your project's Git repository, which will enable Vercel to deploy your latest commits to main without terminal commands.
Once your app is deployed, it will start tracking visitors and page views automatically.
/_vercel/insights/view when you visit any page.
Once your app is deployed and users have visited your site, you can view your analytics:
After a few days of visitors, you'll be able to start exploring your data by viewing and filtering the panels.
Now that you have Vercel Web Analytics set up, explore these resources to learn more:
Learn more about how Vercel supports privacy and data compliance standards with Vercel Web Analytics.