Analytics best practices

Some recommended best practices to follow when sending Vitally your customer data.

Track accounts & users immediately on creation

When you create an account in your database, immediately sending data about that account to Vitally helps your team stay in sync. The same goes for users. Call the Vitally Account API as soon as possible, right after the account is first created in your database. This can be done in the API endpoint where the account is created or within the 'context' of the account creation (e.g. ActiveRecord's after_insert). Either way, we recommend tracking account and user creation events immediately from your server.

Update account data daily

Not every account is active every day. But, you may have traits on the account that change through background processing. That's why we recommend updating every one of your accounts' data in a recurring daily process. This way, you know that your accounts are updated every day in Vitally, and you don't have to worry about scattering API calls to update accounts throughout your codebase. Use the Batch API here to more efficiently send your data.

Track on the server when possible

When sending data to Vitally, you can send from either the client or the server. While there are some events that can only be tracked from the browser, if you can track an event from the server, we've found that delivery is much more reliable.

To not block the server endpoint from returning, we recommend sending the request to our API asynchronously and using the batch API where possible.

Track creates, updates, and deletes of important product elements

To track how successful an account is at using your product, we believe that it is extremely useful to track how they have setup & continue to engage with the core features of your product. That's why we created Elements. To create an Element, you'll need to track when the core parts of your product are created, updated, & deleted, along with an id property to tie those events together.

The create, update, and delete events for a given element in your product most likely correspond to REST endpoints in your server. We recommend tracking those events asynchronously at the end of the API request, after the create/update/delete has been successfully committed to your database.

For example, Vitally tracks the creation of our customers' Elements, Success Metrics, Indicators, Playbooks, and more as Elements in our own internal Vitally account.

Have a consistent naming convention

Naming things is hard! As you expand your product and add new features, if you don't decide on a consistent naming convention, it can become harder and harder to find the right events for analysis. Decide on an naming convention early (e.g. {feature}-{action} or similar), and save your future self the mental energy.

A corollary for this rule is to try to have consistent event property names as well. For example, always calling the database id of an entity id will make creating Elements in Vitally much simpler

Last updated