JavaScript SDK
You can embed Vero’s tracking code in your website using our JavaScript/TypeScript SDK. Below shows how you can get started.This SDK is also available as an NPM package for advanced use cases (e.g., integrating in React or Node.js applications). Please refer to the package’s README for more information.
Install the SDK
You will need the tracking API key to set up the SDK. You can find your API key on the Settings page of your Vero account. Then, insert the following code into your<head> section of every HTML document that you want to track events on, replacing <YOUR_TRACKING_API_KEY_HERE> with your API key.
Identify a user
When a user logs in, you should call theuser.identify method. Both the id and email fields are required.
User to your Vero data store.
You can also attach additional channels or add additional fields to the User profile:
Track an event
AnEvent represents a user action in your application. For instance, when a user takes a specific action or changes state.
user.identify prior to calling event.track, unless you supply an identity object to the method. Once you call user.identify, the SDK will automatically identify the user and store the id and email in the browser’s local storage for future requests.
You can also pass in an optional extras object as outlined in the Track REST API:
Unidentify a user
If a user logs out, you should call theuser.unidentify method so future events will not be accidentally associated with the user.
Advanced usage
Alias/merge a userRuby, PHP and others
Please refer to the respective SDK GitHub repositories (see SDKs above) for how-tos on using the Ruby, PHP and community-supported SDKs.Legacy m.js JavaScript SDK
Prior to 2025, Vero had a legacy JavaScript SDK that was used to interact with the Vero Track API. We recommend using the JavaScript/TypeScript SDK instead, especially for new projects. However, the legacy m.js SDK is still available for use and will continue to be supported.
m.js documentation
Initialize the SDK
Before you can use any of the functions available in the Vero JavaScript SDK, you must first initialize the SDK. To do so, place the following JavaScript on your website, typically in the <head> section of your HTML. We recommend including this on every page.
Insert an active Vero API key. You can manage your API keys under Settings in your Vero Cloud account.
User using the JavaScript SDK either an id or email value are required. All other attributes are optional and customizable. In this example we’re passing a value for the first_name, last_name and subscription properties.
Event represents a user action in your application. For instance, when a user takes a specific action or changes state.
When tracking an Event using the JavaScript library you do not need to pass an identity object as outlined in the Track REST API. Instead, you must make a call to the identify SDK method outlined above. A cookie is then stored and this identity is used by the SDK to form the full API request for you.
Event, the JavaScript SDK supports passing the optional extras object as outlined in the Track REST API.
id. In this example, 123 is the id.

