Follow Web in the Quickstart to create a web app, add the script, and send custom events. This page covers framework-specific setup.
For Next.js applications, use the Script component with the afterInteractive strategy to ensure optimal loading performance. Add this to your _app.js or _app.tsx file:
import Script from 'next/script'
export default function MyApp({ Component, pageProps }) {
return (
<>
<Script
src="https://www.vexo.co/analytics.js"
strategy="afterInteractive"
/>
<Component {...pageProps} />
</>
)
}
The afterInteractive strategy ensures that analytics scripts load after the page becomes interactive, which is the recommended approach for third-party analytics according to the Next.js Script Optimization documentation.