Step 1: Install Usertour.js
You can install Usertour.js in two ways:- For modern web applications using module bundlers (Webpack, Rollup, etc.)
- For traditional web applications or Google Tag Manager
If you’re using a self-hosted Usertour instance, you’ll need additional configuration to connect Usertour.js to your own server. See our Self-Hosted Usertour.js Guide for detailed setup instructions.
NPM Installation
We recommend installing Usertour.js using the usertour.js npm package. First, run this in your Terminal:HTML Snippet Installation
Add this script to your HTML file just before the closing</body> tag:
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
You can send custom user attributes to Usertour.js for more personalized experiences. These can include:- User roles
- Preferences
- Custom metrics
- Any other relevant user data
Optional: Prove user identities
Your environment token is public, so by default anyone holding it could callusertour.identify() with any user ID. To prevent impersonation, your backend can sign an identity token (a JWT) for each user and pass it as identify()’s third argument. See the Identity Verification guide.
Optional: Install Usertour for unauthenticated users
Runningusertour.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(). Usertour.js then assigns the current user a unique ID automatically. Note that these users count towards your MAU balance.
Learn more about anonymous user identification →