Install Userpilot on Your Web App
In order to trigger Experiences live on your app, you must install the Userpilot script on your product or site.
Installing Userpilot on your web app is very easy, and will only take a few minutes to do so.
All you have to do is copy the scripts below and paste them before the closing </head>
tag on every page of your web application.
<script> window.userpilotSettings = {token: "appToken"}; </script> <script src = "https://js.userpilot.io/sdk/latest.js"></script>
Important: If you are copy-pasting the above example code, then don't forget to fill in the "App Token" with your own app token. If you are already a user, click here to find your "App Token".
Note: If your web app runs on a Single Page Application framework, then you should refer to this article in order to make sure Userpilot is fully optimized and running efficiently.
Identifying Users and Accounts
Userpilot allows you to identify each user in your application through the identify method. You must pass a "UNIQUE USER ID" to userpilot.identify as shown in the instructions below.
The more information you pass, the more power you will have at your hands so it's a very good idea to pass other user attributes such as Full Name, Email Address, and Created_at as shown in the instructions above to help you target certain user segments such as new users.
You can also pass a company attribute/object in userpilot.identify
to create company entries in Userpilot analytics and associate a group of users to a single company.
<script> userpilot.identify( "UNIQUE USER ID", // Used to identify users { name: "John Doe", // Full name email: "customer@example.com", // Email address created_at: '2019-10-17', // ISO8601 Date company: { id: 1, // Required, used to identify the company name: "Acme Labs", created_at: '2019-10-17' // ISO8601 Date }, // Additional properties // projectId: "1", // trialEnds: '2019-10-31' // ISO8601 Date } ); </script>
Note: If your user’s data changes in some way without a page load, you should call the userpilot.identify() method. This will cause Userpilot to check for any new changes to the user’s data. You only need to include whatever has changed — you don’t need to include all user data in each update.
userpilot.identify("<UNIQUE USER ID>", // Used to identify users { plan: "paid" } );