Create a Vexo account here (skip if you already have one).
Create a Web App:
Add the Vexo Script
To start collecting Web analytics data, paste the following script into your site’s <head> tag:
<script src="https://www.vexo.co/analytics.js" defer></script>
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.
You can enhance your analytics by tracking custom events and identifying devices:
global?.vexo?.customEvent('purchased-completed', { amount: 24.99 });
global?.vexo?.identifyDevice('user@example.com');
That’s it! Once the script is live on your site, Vexo will start capturing user sessions, session replays, custom events, and more — just like it does on mobile.