Installation
Installing Usertour.js
Usertour.js is a lightweight JavaScript library (~20 kB) that loads asynchronously, ensuring it won’t impact your page load performance. Follow these simple steps to integrate it into your web application.
Installation Methods
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
NPM Installation
We recommend installing Usertour.js using the usertour.js npm package.
First, run this in your Terminal:
Then import and initialize it in your code:
HTML Snippet Installation
Add this script to your HTML file just before the closing </body>
tag:
Configuration
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.
Additional Features
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
Anonymous Users
For public pages where users aren’t logged in, use usertour.identifyAnonymous()
instead of usertour.identify()
. This automatically generates a unique ID for anonymous users.