User Identification
Identify users to connect anonymous sessions with known profiles for deeper insights.
By default, Vemetric will track the data of your users anonymously and without using cookies. In order to do that, we use a combination of the IP address, the user agent and a daily rotating Salt as a hashed id for each user. That also means that on the following day, anonymous users will count as new users.
But as Vemetric is also a product analytics tool, it enables you to identify users, which allows you to connect anonymous activity to a known user once he is authenticated.
Identify users
To identify users, you can use the identify
function of the HTML Script or the NPM Package. When calling it you need to provide a unique identifier for the user. We highly recommend using the primary id of your user in your database. You should call this function after initialization of the SDK, once you know the user is authenticated.
This will create a user profile and from then on, all tracked events will be associated with the identified user. Also existing events sent from the anonymous user session, will be merged with the identified user.
By default, no cookies will be used event after identifying a user. In case you have the consent of your authenticated users, you can pass allowCookies: true
to the identify
function. This will make the event tracking for identified users more accurate. I highly recommend to use a proxy in this case, to ensure a first-party cookie is being used.
HTML script
To identify users with the HTML script, you can call the identify
function like this:
Look at the HTML script docs for a detailed explanation of the available parameters. For example you can also pass a data
object to set additional attributes for the user.
NPM Package
To identify users with the NPM package, you can call the identify
function like this:
Look at the NPM Package docs for a detailed explanation of the available parameters. For example you can also pass a data
object to set additional attributes for the user.
Merging data from anonymous users
As soon as you identify a user, all events from the anonymous user session will be merged with the identified user. In other words, all the actions the user took before logging in can now be linked to the same user. This gives you a continuous view of the user’s journey from first visit to sign-up and beyond.
For example if a user visits your website for the first time via a blog post, then visits pricing, and later signs up, you got all of that connected under that user’s profile and see how they got aware of your product.
Updating user data
Once you have identified a user, you can update their data by calling the updateUser
function. This lets you add additional attributes to the user or update existing ones, so you can later use them to filter and group users in Vemetric.
To update a user’s data you can pass an object with the following properties:
set
: An object containing key-value pairs of attributes to set. If the user already has the attributes, the values will be overwritten.setOnce
: An object containing key-value pairs of attributes to set only if they don’t already exist on the user.unset
: A string array of attribute keys to remove from the user.
All of these properties are optional, so you can also only pass one of them to update the user’s data.
HTML script
To update a user’s data with the HTML script, you can call the updateUser
function like this:
NPM Package
To update a user’s data with the NPM package, you can call the updateUser
function like this:
Reset user
When a user logs out, you should reset the user in Vemetric, so that following events won’t be associated with the user anymore.
HTML script
To reset a user with the HTML script, you can call the resetUser
function like this:
NPM Package
To reset a user with the NPM package, you can call the resetUser
function like this:
Track meaningful user actions by sending custom events with Vemetric.
Visualize and analyze the full journey of users across your product with Vemetric.