The following functions allow you to manipulate with userId setting and user progress. They are available on all pages where the Usetiful script is installed.
window.USETIFUL.user.setId(userId)
- This function allows you to set the userID of the current user.
window.USETIFUL.user.setId("user_123"); // set userId window.USETIFUL.reinitialize(); window.USETIFUL.user.setId(null); // remove userId window.USETIFUL.reinitialize();
To apply the changes, you should call the window.USETIFUL.reinitialize() function after the userId is changed. If the localStorage doesn't contain any progress, it will load progress from Usetiful server and store it in the local storage.
This is mainly useful when you need to set it up later the usetiful script is loaded. Otherwise, you can define userID as usetifulTag before the embedding code.
window.usetifulTags = { userId: 'user_123' };
window.USETIFUL.user.clearProgress()
- This function removes the progress of the current user from the local storage. Data remains stored on the Usetiful server.
- This function is helpful also when you need to switch between users on just one device. If you don't clear progress on the logout action, could be the existing progress from the local storage stored in the Usetiful server for the next user accessing the system which is not desired state.