Overview
To display Userpilot content to users who aren’t logged in or are browsing your public website anonymously, you can utilize theuserpilot.anonymous()
function. This method allows Userpilot to automatically generate a unique user ID, enabling the display of targeted content without requiring any user-specific data.
Implementation Steps
-
Include the Userpilot Script:
Insert the following script into the
<head>
section of your webpage:Replace"appToken"
with your actual Userpilot application token. -
Initialize Userpilot Anonymously:
After including the script, call the
userpilot.anonymous()
function:This function generates a unique user ID, allowing the user to view the triggered content without the need to pass any personal data.Keep in mind that users accessing pages with the Userpilot script installed are counted as monthly active users (MAU). Userpilot tracks the number of unique users who have logged into the system over the past 30 days. Therefore, to be counted towards your MAU, a user must be identified using eitheruserpilot.identify()
oruserpilot.anonymous()
, ensuring they are recognized as unique users within the specified period.
Restricting Content to Anonymous Users
If you wish to display specific Flows, Checklists, Spotlights, or Resource Center modules exclusively to anonymous users, adjust the Audience condition as follows: Set the condition to ‘User Data’ => ‘user id’ => doesn’t exist.
Any Userpilot content with the Audience setting set to “All users” will appear for the anonymous user.
userpilot.anonymous()
function, you can effectively engage with anonymous users, providing them with tailored content and enhancing their overall experience on your platform.