Usertour.js Installation
Before your users can see the content you build, you need to install Usertour.js in your web app.
Usertour.js is a tiny piece of JavaScript code (~20 kB), which is loaded asynchronously in your web app, so it won’t affect your page load speed.
The installation is simple and only requires 2 quick steps:
Step 1: Install Usertour.js
Usertour.js can be installed in one of 2 ways:
- Browser apps using module bundlers (such as Webpack or Rollup)
- Other browser apps and Google Tag Manager
Npm installation
We recommend installing Usertour.js using the usertour.js npm package.
First, run this in your Terminal:
Import and use the usertour
object from the usertour.js
module:
Important: Make sure to replace the placeholders with real, dynamic values from your app! See Step 2.
HTML snippet installation
Copy-paste the folloidfsafawing snippet into your HTML document before the ending tag:
Important: Make sure to replace the placeholders with real, dynamic values from your app! See Step 2.
Step 2: Replace placeholders
In the code you copy-pasted above, replace USERTOUR_TOKEN with the Usertour.js Token you find under Settings -> Environments. Note that if you have multiple environments (e.g. Production and Staging) that each environment has a unique token.
Next, replace USER_ID with the currently signed in user’s ID in your database. Also replace USER_NAME, USER_EMAIL and USER_SIGNED_UP_AT with the user’s real, dynamic values. signed_up_at should be specified in ISO 8601 format. Example: 2019-12-11T12:34:56Z.
The properties in usertour.identify()‘s second argument are all optional. They’re useful for looking up users in Usertour to e.g. see their flow progress, or to use in the flow content or conditions. If you don’t want to share this with Usertour, feel free to leave out the argument completely.
That’s it! Your Usertour installation is ready.
Optional: Add custom attributes
Usertour.js supports sending custom attributes: Key-value pairs of data such as user role or other preferences. See Usertour.js Reference for how to use attributes.
Optional: Install Usertour for uauthenticated users
Running usertour.identify() is a mandatory part of the script. But if you want to show Usertour content on public pages to users who are not yet signed into your application, you can install the script on those pages and replace usertour.identify() with usertour.identifyAnonymous(). With this function Usertour.js will automatically assign the current user a unique ID. But note that they will count as users in the MAU balance.