Introduction
Introduction to Usertour.js SDK and its core features
Introduction
Usertour.js is a lightweight client-side SDK that enables you to:
- Identify and track users in your web application
- Display interactive content (flows) to your users
- Collect user behavior data for targeting
Follow us on Twitter for the latest updates and announcements.
Core Methods
Here are the most commonly used methods:
Method | Description |
---|---|
usertour.init() | Initialize the SDK with your Usertour.js Token |
usertour.identify() | Identify and track a user |
usertour.group() | Associate a user with a company/group |
Installation
Recommended: NPM Installation
We recommend using the npm package for the best development experience:
For alternative installation methods, see Usertour.js Installation Guide.
Quick Start
Add this code to your application where you have access to user information:
Important Notes
Replace Placeholders
- Replace all placeholders (e.g.,
<USERTOUR_TOKEN>
,<USER_ID>
,<NAME>
,<EMAIL>
) with your actual values - The
signed_up_at
timestamp should be in ISO 8601 format
Getting Your Token
- Find your Usertour.js Token in Settings -> Environments
- Each environment (Production, Staging, etc.) has its own unique token
- Make sure to use the correct token for your environment
How It Works
The npm package (usertour.js
) is a thin wrapper around the real Usertour.js, which is loaded from our CDN. This design allows you to interact with the imported usertour object immediately. When you make your first method call, the real Usertour.js will be automatically loaded (asynchronously) and injected into the current page. All method calls are automatically queued by the usertour object until the SDK is ready.
The core SDK is optimized for performance:
- Small footprint (less than 16 KB gzipped)
- Loads UI components only when needed
- Supports both modern and legacy browsers
If you’ve installed Usertour.js via a <script>
tag, you can access the object via window.usertour
. However, be aware that it may not be immediately available, which is why we recommend using the npm package.
Attributes
The SDK provides a flexible attribute system for storing data about various entities like users, companies, and events. You can use this to store a user’s name, a company’s plan type, or decorate events with information like which billing plan was selected. These attributes can then be used within Usertour to segment users, personalize flows, or track behavior.
When updating objects with attributes, you can use various data types:
Type | Description | Example | Common Use |
---|---|---|---|
string | Text values | "John Doe" | Names, emails |
number | Numeric values | 42 or 1234.56 | Scores, metrics |
boolean | True/false values | true or false | Feature flags |
datetime | ISO 8601 timestamps | "2023-06-14T16:25:49Z" | Event times |
list | Arrays of strings | ["tag1", "tag2"] | Tags, categories |
Here’s how to use attributes in your code:
For best results, we recommend:
- Using consistent naming conventions (lowercase with underscores)
- Choosing appropriate data types for each attribute
- Avoiding storage of sensitive information