Skip to content
Last updated on June 6, 2023
3 min read
Audiences has been renamed to Web Analytics. Speed Insights remains as a separate product that allows you to track app performance.

With the @vercel/analytics npm package you're able to configure your application to send analytics data to Vercel.

To get started with analytics, please follow our Quickstart guide which will walk you through the process of setting up analytics for your project.

Override the automatic environment detection. This option allows you to force a specific environment for the package. If not defined, it will use auto which tries to set the development or production mode based on available environment variables such as NODE_ENV.

If your used framework does not expose these environment variables, the automatic detection won't work correctly. In this case, you're able to provide the correct mode manually or by other helpers that your framework exposes.

If you're using the <Analytics /> component, you can pass the mode prop to force a specific environment:

pages/_app.jsx
import { Analytics } from '@vercel/analytics/react';
 
<Analytics mode={'production'} />;

You'll see all analytics events in the browser's console with the debug mode. This option is automatically enabled if the NODE_ENV environment variable is available and either development or test.

You can manually disable it to prevent debug messages in your browsers console.

If you're using the <Analytics /> component, you can pass the debug prop to disable the debug messages while developing locally:

pages/_app.jsx
import { Analytics } from '@vercel/analytics/react';
 
<Analytics debug={false} />;

With the beforeSend option, you can modify the event data before it's sent to Vercel. Below, you will see an example that ignores all events that have a /private inside the URL.

Returning null will ignore the event and no data will be sent. You can also modify the URL and check our docs about redacting sensitive data.

If you're using the <Analytics /> component, you can pass define a function and pass it to beforeSend:

pages/_app.jsx
import { Analytics } from '@vercel/analytics/react';
 
<Analytics
  beforeSend={(event) => {
    // Ignore all events that have a `/private` inside the URL
    if (event.url.includes('/private')) {
      return null;
    }
    return event;
  }}
/>;