1 min read
Vercel Web Analytics now supports tracking custom events on the server-side, in addition to existing support for client-side tracking.
app/page.tsx
import { track } from '@vercel/analytics/server';
export default function FeedbackPage() { async function submitFeedback(data: FormData) { 'use server';
await track('Feedback', { message: data.get('feedback') as string, }); }
return ( <form action={submitFeedback}> <input type="text" name="feedback" placeholder="Feedback" /> <button type="submit">Submit Feedback</button> </form> );}
Tracking a server-side event with a Server Action in Next.js.
Events can now be tracked from Route Handlers, API Routes, and Server Actions when using Next.js (or other frameworks like SvelteKit and Nuxt) through the track
function.
Custom event tracking is available for Pro and Enterprise users.
Check out the documentation to learn more.