Nuxt Vercel Analytics
Vercel Web Analytics integration for Nuxt
Features
- Zero-config
- Auto-imported
track
function aliased as vercelTrack
Setup
- Add
nuxt-vercel-analytics
dependency to your project
pnpm add -D nuxt-vercel-analytics
yarn add --dev nuxt-vercel-analytics
npm install --save-dev nuxt-vercel-analytics
- Add
nuxt-vercel-analytics
to the modules
section of nuxt.config.ts
export default defineNuxtConfig({
modules: ["nuxt-vercel-analytics"],
});
That's it! Vercel Analytics is now integrated in your Nuxt app ✨
Configuration
export default defineNuxtConfig({
modules: ["nuxt-vercel-analytics"],
vercelAnalytics: {
mode: "auto",
debug: true,
beforeSend: (event) => {
if (event.url.includes("/private")) return null;
return event;
},
},
});
Custom Events
To track an event, call vercelTrack
and pass in a string representing the event name as the first argument
const onSignup = () => {
vercelTrack("Signup");
};
Custom data
You can also pass custom data along with an event by passing an object as the second argument
const onSignup = () => {
vercelTrack("Signup", { location: "footer" });
};
Development
npm install
npm run dev:prepare
npm run dev
npm run dev:build
npm run lint
npm run test
npm run test:watch