The following functions allow you to manipulate userId, tags, and user progress. They are available on all pages where the Usetiful script is installed.


User ID settings

User ID is an essential tag for syncing user progress across devices. Read more on User ID for the cross-device support.


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'
    };


Dynamic user tags settings


window.USETIFUL.user.setTag(name, value)

  • You can set individual usetiful tag.
  • window.USETIFUL.user.setTag('test', ‘value1');


window.USETIFUL.user.setTags({name: value, name2: value2})

  • This function can be used to set up multiple tags at once.

    window.USETIFUL.user.setTags({ test: ‘value3', test2: 'value4' });



Removing user tags


If the following functions are called with the userId tag defined, tags may be deleted for given user also from the Usetiful server.


window.USETIFUL.user.removeTag(name)

  • This function removes a specific tag from local storage and window.usetifulTags object.
  • window.USETIFUL.user.removeTag(’test’);


window.USETIFUL.user.removeAllTags()

  • This function removes all tags from local storage and window.usetifulTags object


Removing user progress

Sometimes it is necessary to remove the user progress. This is useful when you need to switch between multiple users on one device. If you do not remove progress during a logout action, the existing progress from the local storage may be stored on the Usetiful server for the next user accessing the system.


If the following function is called with the userId tag defined, the progress can be deleted for given user also from the Usetiful server.


window.USETIFUL.user.clearProgress()

  • This function removes all data related to user progress in the local storage. It includes keys storing data about tours, checklists, smart tips, and also tags.
  • For removing the progress on user logout, we recommend to call this sequence of functions:
    window.USETIFUL.user.setId(null); // remove userId
    window.USETIFUL.user.clearProgress(); // remove progress
    window.USETIFUL.reinitialize();