Client-Side Tracking

In addition to server-side tracking, Userlist also allows client-side tracking — via the same tracking script that powers in-app messages. See this article on how to include a JavaScript snippet in your application's layout for signed-in users.

The same tracking script allows you to update the user's properties and to track custom events in the client's browser.

Please ensure that these calls are made after the included tracking script, either by placing these calls below the script tags in your HTML or by using the page load event to delay execution.

Sending Users

The tracking script exposes a global userlist function that receives a method name and a list of arguments. To update user properties, please use the identify method, followed by a object of properties. Please see the integration guide for a list of available properties.

1
2
3
4
5
6
7
userlist('identify', {
  email: 'foo@example.com',
  properties: {
    first_name: 'Foo',
    last_name: 'Example'
  }
});

Sending Events

In order to track custom events, use the track method name and pass the event name as a second argument. Optionally, you can pass additional properties of the event as a third argument.

1
2
3
4
5
// Track a custom event
userlist('track', 'project_created');

// Track a custom event with event properties
userlist('track', 'project_created', { name: 'Example project' });

Reset

By default, the connection to Userlist's servers will be closed and re-established on page load. Passing a new token for a different user will gracefully switch users.

For single page applications, it's possible to reset the current connection by calling destroy. This will close the connection to the server and allows the use of a new token.

1
userlist('destroy');

Afterwards you can setup a new connection with a new token.

1
userlist('init', 'insert-generated-user-token-here');

Book your discovery demo

See how Userlist can help your business unlock new opportunities for product-led growth. Learn how Userlist integrates with your existing tools, and what the growth journey looks like.