Standard
In this guide, we will take a closer look at how to properly handle device registration within Actito.
When you invoke launch() for the first time, the SDK registers the device as a non-push device. This initial registration enables Actito to begin tracking user engagement, categorizing users through tags, and enriching user profiles with known data.
Device registration is a fundamental component of how Actito operates and underpins many of its core features.
You can view the current device information at any time using:
import { getCurrentDevice } from 'actito-web/core';
const device = getCurrentDevice();
Once launch() completes, the SDK is fully initialized and ready for interaction.
By default, all visitors to your website are automatically registered as users — even if they do not grant permission to receive push notifications.
If you prefer to disable this behavior and register only users who explicitly allow push notifications, you can do so [directly in your Actito app].
Assigning a User to the Device
By default, a newly registered device is associated with an anonymous user. However, in applications where users authenticate, you should explicitly associate the device with the authenticated user’s information.
This can be achieved as follows:
import { updateUser } from 'actito-web/core';
await updateUser({
userId: '7f42bedc-d74b-4c64-a5cf-76bcc5130b05',
userName: 'John Doe',
});
After this call, the device remains linked to the provided userId and userName until they are explicitly cleared. Depending on your authentication flow, you may wish to verify the user’s login state after launching and update the registration accordingly.
To reset the device to an anonymous user, set both parameters to null:
import { updateUser } from 'actito-web/core';
await updateUser({
userId: null,
userName: null,
});
Overriding the device language
By default, Actito automatically detects the device’s language and region based on the system Locale. In most scenarios, this behavior is sufficient. However, if you need to enforce a specific language and region combination — for instance, when your app supports a limited set of locales — you can override the default by invoking:
import { updatePreferredLanguage } from 'actito-web/core';
await updatePreferredLanguage('en-US');
You can retrieve the currently configured preferred language at any time with:
import { getPreferredLanguage } from 'actito-web/core';
const preferredLanguage = getPreferredLanguage();