Managing Usage & Costs
Speed Insights is available on all plans
This guide covers how to measure and reduce your Speed Insights usage using the @vercel/speed-insights package.
Your Speed Insights usage over time is displayed under the Speed Insights section of the Usage tab on your dashboard.
To learn more about data points and how they are calculated, see Understanding data points.
To reduce the number of data points collected, you can configure the @vercel/speed-insights package with the following options. First, install the package if you haven't already:
npm i @vercel/speed-insightsThen configure one or both of the following options:
The sampleRate option determines the percentage of events sent to Vercel. By default, all events are sent. Lowering this value reduces the number of data points collected, which can lower costs while still providing statistically meaningful performance data.
For example, setting sampleRate to 0.5 means only 50% of page views will send performance metrics:
Lower sample rates reduce costs but may decrease data accuracy for low-traffic pages.
The beforeSend option lets you filter or modify events before they reach Vercel. You can use this to exclude specific pages from tracking, which reduces the total number of data points collected.
Common use cases include:
- Excluding internal or admin pages that don't need performance monitoring
- Excluding pages that aren't user-facing
To exclude events from specific paths, return null from the beforeSend function:
<SpeedInsights
beforeSend={(data) => {
// Exclude admin pages
if (data.url.includes('/admin')) {
return null;
}
// Exclude internal tools
if (data.url.includes('/internal')) {
return null;
}
return data;
}}
/>If you want to track only certain pages, you can invert the logic to create an allowlist:
<SpeedInsights
beforeSend={(data) => {
// Only track the homepage and product pages
const allowedPaths = ['/', '/products', '/pricing'];
const currentPath = new URL(data.url).pathname;
if (allowedPaths.some((path) => currentPath.startsWith(path))) {
return data;
}
return null;
}}
/>For maximum cost control, you can combine both options. The sampleRate determines at page load whether to collect vitals, then beforeSend filters events before sending:
<SpeedInsights
sampleRate={0.5}
beforeSend={(data) => {
// Exclude admin pages entirely
if (data.url.includes('/admin')) {
return null;
}
// Of the 50% of page views sampled, admin pages will be excluded
return data;
}}
/>Was this helpful?