Skip to content
6 min read

Tracking custom events

Learn how to send custom analytics events from your frontend application.
Table of Contents
Choose a framework to optimize documentation to:

Custom Events are available on Pro and Enterprise plans

Vercel Web Analytics allows you to track custom events in your frontend application using the va.track() function. This is handy for tracking user interactions, such as button clicks, form submissions or purchases.

Make sure you have version 1.0.0 or later of @vercel/analytics installed.

To track an event, call va.track() and pass in a string representing the event name as the first argument.

import va from '@vercel/analytics';
// Call this function when a user clicks a button or performs an action you want to track

This will track an event named Signup.

In most cases you will want to track an event when a user performs an action, such as clicking a button or submitting a form.

For example, if you have a button that says Sign Up, you can track an event when the user clicks the button:

import va from '@vercel/analytics';
function SignupButton() {
  return (
      onClick={() => {
        // ... other logic
      Sign Up

It’s important to note that custom events can only be tracked on the client-side. Server-side events are not currently supported by Vercel Web Analytics.

You can also pass custom data along with an event by passing an object as the second argument to va.track(). The object should contain key-value pairs, where the keys and values can only be strings, numbers, booleans, or null. Note that the number of custom data properties you can pass is limited based on your plan. See the pricing documentation for more details.

custom data
va.track('Signup', { location: 'footer' });
va.track('Purchase', { productName: 'Shoes', price: 49.99 });

This will track a "Signup" event and also includes the information that the event occurred in the "footer" location. The second event will track a "Purchase" event with product name and a price.


  • Nested objects are not supported
  • Allowed values are strings, numbers, booleans, and null
  • Event name, key and values should be no longer than 255 characters
Last updated on September 29, 2023