Naming Events
It's important to come up with a standardized pattern for events, that way we know what to look for and how to construct funnels and cohorts.
Most analytics tools, including Mixpanel, use a single string to identify an event. That string can be pretty much anything, so it's up to us to organize what those strings look like.
Object-Action Framework
I found an article by Compass describing (opens in a new tab) a pattern called the Object-Action framework. This seems like a good mental model to branch off of.
Adding A Name
While their guide only outlines Objects and Actions, I think it's important to add one more tier, Name
, for filtering more specifically.
Rules
- Each piece of a name (
Object
,Action
,Name
) is called a "tier" - Tiers are separated by an underscore
_
- Multi-word names are separated by a dash
-
- An
Object
andAction
are required, aName
is optional - The order they appear in a string is
Object
first,Action
second, andName
third
Examples
page_viewed_interfacer
page_viewed_home-screen
checkout_begun
header-button_clicked_docs
user_created
request_made_get
request_made_patch
Tracking The Most Narrow Events
With this approach, we can embrace the flexibility and hierarchy to track multiple events at once if a Name
is used.
For example, if we're tracking a request, we'll make the most specific call track('request_made_patch')
. Within that track function, we can actually track two events: the request and the patch request. With the names delineated via underscores, we can do some logic like this:
function track(eventName) {
const [object, action, name] = eventName.split("_");
if (name) {
sendTrackEvent(`${object}_${action}`); // Track the broader event as well
}
sendTrackEvent(eventName);
}
Inside our interface, we can now do a filter comparing the frequency of a given Name
inside a given Object Action
. For example, imagine each link in a header has an event: header-link_click_docs
or header-link_click_dashboard
. We can then see the event header-link_click
happened 500 times, and the majority, lets say 400, of those were on header-link_click_dashboard
. Then we would know to emphasize that dashboard link.