supastarter for Next.jsAnalytics
Overview
Learn how to use analytics in supastarter.
supastarter comes with a generic analytics module that enables you to integrate analytics providers and track custom events.
Setup analytics
In the apps/web/modules/analytics/index.ts
file, export the provider file of the provider you want to use:
To learn how to set up your analytics provider, check out the respective documentation:
Analytics script component
The analytics script component that is part of the provider file you exported in the first step is automatically included in the application:
Now your app will include the analytics script and track page views.
Track custom events
To track custom events, import the useAnalytics
hook and use the trackEvent
function:
The trackEvent
function takes two arguments:
event
: The name of the eventdata
: An object containing additional data about the event