Skip to main content

Overview

Userpilot provides two key functions for managing user sessions and content targeting: userpilot.identify and userpilot.reload. Understanding when and how to use each is essential for accurate user tracking and seamless content delivery, especially in modern web applications and Single Page Apps (SPAs).

userpilot.identify

The userpilot.identify function is used to uniquely identify a user and set their properties. This is typically called on the first page load after authentication, but can also be called whenever user properties change. When to use:
  • On initial page load after user authentication.
  • Whenever user properties (such as name, plan, or preferences) change during a session.
Example: Initial identification
Example: Updating user properties If a user changes a property (e.g., their app color), you can call identify again with the new property:
You can call userpilot.identify multiple times on the same page as user properties change.

userpilot.reload

The userpilot.reload function refreshes Userpilot content based on the current page state or URL. This is especially important in Single Page Applications (SPAs), where the URL or page content can change without a full page reload. When to use:
  • After calling userpilot.identify (never before).
  • On every route or URL change in SPAs (e.g., React, Angular, Vue).
  • When you want Userpilot to re-evaluate which content to show based on the new page state.
Example: React route change
Example: Angular router events
Example: Vue router
Note: Calling userpilot.reload before identifying the user will have no effect. Always ensure the user is identified first.

Summary Table


For more details, see the JavaScript SDK Reference or contact support@userpilot.com.