Skip to main content

Prerequisites

Before you begin, you’ll need:
  • A Vero account (sign up here if you don’t have one)
  • Your Tracking API key, found on the Settings page of your Vero account

Choose your integration method

Install the JavaScript SDK

Add the following to the <head> section of every page you want to track, replacing <YOUR_TRACKING_API_KEY_HERE> with your API key. You can find your Tracking API key on the Settings page of your Vero account.
<script src="https://cdn.jsdelivr.net/npm/@getvero/tracking@latest/dist/index.window.js"></script>
<script>
    vero.tracker.init({
        trackingApiKey: "<YOUR_TRACKING_API_KEY_HERE>"
    })
</script>
This SDK is also available as an NPM package for advanced use cases (e.g., integrating in React or Node.js applications). Refer to the package’s README for more information.

Identify a user

When a user logs in, call user.identify with their id and email (both required). This adds or updates the user in your Vero data store.
vero.tracker.user.identify({
    id: "<USER_ID_HERE>",
    email: "<USER_EMAIL_HERE>"
})
You can also attach additional channels and custom data to the user profile:
vero.tracker.user.identify({
    id: "<USER_ID_HERE>",
    email: "<USER_EMAIL_HERE>",
    channels: [
        {
            type: "push",
            address: "<PUSH_TOKEN_HERE>",
            platform: "android"
        }
    ],
    data: {
        first_name: "<FIRST_NAME_HERE>",
        last_name: "<LAST_NAME_HERE>"
    }
})
Once identified, users will appear in the Profiles section of your Vero account where you can view their properties, channel addresses, and activity history. Learn more about user profiles.

Track an event

An event represents a user action in your application, such as viewing a product or completing a purchase.
vero.tracker.event.track({
    eventName: "viewed product",
    data: {
        product_name: "Red T-shirt",
        product_url: "https://www.example.com/products/red-t-shirt",
    }
})
You must call user.identify before calling event.track, unless you supply an identity object to the method. Once you call user.identify, the SDK stores the id and email in local storage for future requests. Tracked events will appear on the Events page in your Vero account, where you can view recent occurrences, event properties, and which campaigns use each event as a trigger. Learn more about events in Vero.

Unidentify a user

When a user logs out, call user.unidentify so future events are not associated with them.
vero.tracker.user.unidentify()