Skip to main content
This is the legacy m.js JavaScript SDK. We recommend using the JavaScript/TypeScript SDK for all new projects. The legacy SDK will continue to be supported but is no longer actively developed.

Initialize the SDK

Place the following JavaScript 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.
var _veroq = _veroq || [];
_veroq.push(["init", {api_key: "INSERT_API_KEY"}]);

(function () {
    var ve = document.createElement("script");
    ve.type = "text/javascript";
    ve.async = true;
    ve.src = "//d3qxef4rp70elm.cloudfront.net/m.js";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(ve, s);
})();

Add or update a user

When adding a user, either an id or email value is required. All other attributes are optional and customizable.
_veroq.push([
    "user",
    {
        id: "123",
        email: "damienb@getvero.com",
        first_name: "Damien",
        last_name: "Brzoska",
        subscription: "medium",
    },
]);

Track an event

An event represents a user action in your application. You do not need to pass an identity object as outlined in the Track REST API. Instead, you must call the identify SDK method above. A cookie is then stored and this identity is used by the SDK to form the full API request for you.
_veroq.push([
    "track",
    "viewed product",
    {
        product_name: "Red T-shirt",
        product_url: "http://www.yourdomain.com/products/red-t-shirt",
    },
]);
The JavaScript SDK also supports passing the optional extras object as outlined in the Track REST API:
_veroq.push([
    "track",
    "viewed product",
    {
        product_name: "Red T-shirt",
        product_url: "http://www.yourdomain.com/products/red-t-shirt",
    },
    {
        source: "My application",
        created_at: "2024-08-01 10:05",
    },
]);

Alias / merge a user

The alias method merges two user identities into one. This is an advanced method and may have unintended consequences. Please get in touch if you have questions regarding its usage.
_veroq.push([
    'reidentify', {
        '456', // The new user ID
        '123'// The old user ID
    }]);

Add or remove tags

Tags are one way to assign states or temporary attributes to users. For new use cases we encourage you to update a user attribute rather than use a tag.
_veroq.push([
    "tags",
    {
        id: "123",
        add: ["prospect"],
        remove: ["customer"],
    },
]);

Unsubscribe and resubscribe

Supply the user’s id. In this example, 123 is the id.
_veroq.push(["unsubscribe", "123"]);
_veroq.push(["resubscribe", "123"]);

Delete a user

Users cannot be deleted via the legacy JavaScript SDK. Use the Track REST API or the current JavaScript SDK instead.