Analytics For Windsor

caution

Windsor works best when you to use Segment for analytics.

We are working on releasing our own SDKs soon. Currently, a node.js SDK is in beta. For now, we recommend setting up a free Segment account here before moving on.

In addition to any tracking code you may already have, we have a few recommendations to make the best of Windsor

identify()

known as user() in windsor-node

The Segment identify method is the best way to add metadata to a user. Call identify() with any property you'd like to track about a user. Windsor needs a userId and email for most integrations to work correctly. Additionally, a value for phone will let Windsor track any text messages you send. The avatar property lets you identify users easily on Windsor.

analytics.identify("user-123", {
name: "John Doe",
email: "john@example.com",
avatar: "https://avatar.windsor.io/user-123",
phone: "+1 (415) 123-4567",
});

You may track any additional properties you'd like. When deciding what to name those properties, refer to the Segment traits spec.

We recommend calling the identify() method as often as possible from your app, both on the frontend and backend. This is because ad-blockers can prevent analytics events on the frontend. As a general guide, call identify() -

  • On Sign up
  • On Every Login (preferably on the client and server)
  • Every time a core user property changes (name, email, avatar or phone number)
  • Upon Loading any pages that are accessible by a logged in user

Choosing a userId

Every identified user must be assigned a unique userId so they can be tracked consistently across different browsers or devices. You should assign new users their userId at the point that they register.

We recommend using database IDs instead of simple email addresses or usernames, because database IDs never change. That guarantees that even if the user changes their email address, you can still recognize them on Windsor. And even better, you’ll be able to correlate analytics data with your own internal database.

After Identification

After any call to identify(), we strongly recommend you follow up with a call to track() (see more details on that method below). This is so you can track what the reason for a call to identify was. For example, if the user just signed up, call track with analytics.track("Signed Up"). If the user updated their profile, analytics.track("Updated Profile", { favoriteColor: "black" }). The identify call will actually update the user property on Windsor, but the corresponding event will explain to you what caused the change.

track()

known as event() in windsor-node

Your app should call track() for every important action a user takes. Segment has a great guide on what events are important to track for each industry.

Additionally, Windsor understands specific events to power additional features.

Documentation on these features is in progress

For now, we recommend following Segment's guide for your industry/application to get the best experience with Windsor.