Nuxt Vercel Analytics
Vercel Analytics integration for Nuxt
๐ Features
- ๐ Zero-config
- ๐ฅ Auto-imports
๐ง Setup
- Add
nuxt-vercel-analytics
dependency to your project
# Using pnpmpnpm add -D nuxt-vercel-analytics# Using yarnyarn add --dev nuxt-vercel-analytics# Using npmnpm install --save-dev nuxt-vercel-analytics
- Add
nuxt-vercel-analytics
to themodules
section ofnuxt.config.ts
export default defineNuxtConfig({ modules: ["nuxt-vercel-analytics"],});
That's it! Vercel Analytics is now integrated in your Nuxt app โจ
โ๏ธ Configuration
// app.config.tsexport default defineAppConfig({ 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"); // ...other logic};
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" }); // ...other logic};