Working with Users

The Storyteller SDK requires users to have an externalId set. The externalId should be an identifier which is unique per user and does not change. Therefore, using something like the user's email address is not a good choice for an externalId as the user may change it at some point in the future. However, using a unique UUID/GUID would be a good choice as it is guaranteed to not change over time.

In order to supply the externalId it should be passed to the initialize method:

Storyteller.sharedInstance.initialize('[APIKEY]', { externalId: 'user-id' });

Current User Information

You can access the following information about the current user via the following static variables:

Storyteller.sharedInstance.currentUserId       // Returns the current user id
Storyteller.sharedInstance.currentApiKey       // Returns the current api key

Changing Users

If you support user accounts on your site and wish to allow users to logout and log back in as a new user (or proceed as an anonymous user), then when a user logs out you should call setUserDetails specifying a new externalId. Note that this will reset the local store of which pages the user has viewed.

Storyteller.sharedInstance.setUserDetails({ externalId: 'user-id' });
Forward Arrow