Learn the basics
Updated Jan. 9, 2012Summary
Everything on Mixpanel is based on engagement or actions users will take in your application. Page views are not tracked by default because actions are generally much better indicators of a key metric you might be trying to understand. An action is as simple as a tweet, purchase, video play, or sign up.
To use Mixpanel, you'll end up tracking lots of actions and data around those actions. Each action you'd like to track requires a little piece of instrumentation on your part but once done will activate most of Mixpanel's beautiful reporting instantly.
Events
The first event you should track is something important that frequently occurs in your application. For Twitter, it would be a "Tweet" but for YouTube it might be a "Video Play." You'll want to choose something that is special to your application. We recommend only tracking 3-5 actions you really care about. They should embody things you believe are the most engaging and important parts of your application.
What is a property?
A property is just a little piece of extra information that describes the event a bit better. The point of properties are to allow you to slice and dice your data more easily. For Twitter, they might add a property called "source" which could help identify how the user got to Twitter. For YouTube, they might know the age of the user and add that along with every "Video Play" as to segment on age.
Tracking something simple
mpq.track("Video Play", {"age": 13, "gender": "male"});
- Video Play - An event that you can define to be anything
- age/gender - A property that you can define to be anything
- {"age: 13, "gender": "male"} - A key / value mapping of properties where you can add more
Keep in mind you can simply set the values for a property (e.g. gender) by just setting a variable so you dynamically send the correct age or gender per user on your website.
How do I track unique visitors?
There are two ways to track unique visitors but in a nutshell you can either let Mixpanel automatically identify the visitor or you can more accurately set your own unique identifier. If you decide to do the former then you can skip this section as long as you're using the Javascript library.
To set your own unique identifier which can afford greater accuracy, just call the following line of code in Javascript:
mpq.identify("richard98");
In this case, richard98 is a username but you could use a user_id or anything that uniquely identifies the user.
Related articles
- Read our best practices blog post
