Tracking Events
Using event tracking in Server Actions and Route Handlers
With Simple Analytics for Next.js you can collect events across your application, e.g. button clicks, or form submissions, using the trackEvent
function.
Learn more about events in the Simple Analytics docs.
Tracking client-side events
The client-side trackEvent
function requires the SimpleAnalytics
component to be used to track events in client components.
Adding metadata to events
You can add additional metadata to events to provide more context about the event.
Tracking server-side events
You can also track events in Server Actions and Route Handlers.
However, you must explicitly pass the request
object or the request headers to the trackEvent
function.