Identify Users & Track Custom Events
Identifying users & letting Userpilot track custom events can help you create powerful user segments to target & track goals as well.
The more information you pass, the more power you will have at your hands.
To pass a user attribute, you must call the userpilot.identify() function as shown below.
<script> userpilot.identify( "UNIQUE USER ID", // Used to identify users { name: "John Doe", // Full name email: "customer@example.com", // Email address created_at: "1519205055", // Signup date as a Unix timestamp // Account parameters (optional), used to target users that belong to a certain organization. company: { id: 1, // Required, used to identify the company name: 'Acme Labs', created_at: "1519205055" } // Additional properties // createdProject: "true", // projectId: "1", // trialEnds: '2019-10-31T09:29:33.401Z' } ); </script>
For example, if you want to pass the user attribute projectID, you'd add projectID: 1.
Passing date parameters
You can pass extra date parameters other than the created_at parameter using the ISO 8601 format.
For example, you can pass the date where the trial for a certain user ends as follows trialEnds: '2019-10-31T09:29:33.401Z'
IMPORTANT: If your user’s data changes in some way without a page load, you should call the userpilot.identify() function again.
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.
You can also let Userpilot track custom events for you using the userpilot.track() function.
// You can track your events using the "Track" method <script> userpilot.track("Event"); </script> // You can also specify more information about your event <script> var meta = {URL: "/growth"}; userpilot.track("Page Event", meta); </script>