Integration Walkthrough
Overview
This tutorial covers the process of figuring out what to track, adding the tracking code to your product, and understanding the analysis when you go to your Mixpanel report.
We will be using a Facebook game, Master Chef, to give specific examples.
Events
What should I track?
Master Chef, a cooking game, has a few features that we would like to know more about: when players battle each other and when they do missions.
First we want to to track which missions people are doing.
With a single line of code, we can find:
- How many missions a user completes
- Which missions are most popular
Adding the code
This is the easy part. We have this function that is called each time the user does a mission:

As you can see, we just add one simple line and we're good to go.
Understanding the report
Now that we've added our tracking code and collected a bit of data, we can see some pretty interesting patterns emerge. First, we'll take a look at a time-series graph of missions completed:

Here's the same graph as a pie chart, which makes it easier to compare totals.

From our data so far, we can see that a single mission, open a five-star casino restaurant, makes up more than 20% of all missions completed. We have hundreds of missions, and we may need to work on balancing them if this is one is so much more popular than the others.
Report overview
The first thing we see on the report page is an overview graph. This graph shows the number of daily unique visitors who have triggered each of your events. Below that we find the event table, which holds a bunch of data.

The event table shows us two types of data: on the left is a tallied view, which shows us the totals so far for today as well as yesterday and a week from yesterday, and on the right is a basic retention table.
Funnel analysis
What should I track?
For our game, we want to figure out the percentage of users that progress along the following steps:- Hit the main page
- Invite their friends
- Complete a mission (finish)
Adding the code
Again, adding the tracking code is extremely simple: one line of code per step in the funnel.For step 1, we will track page loads. Step 2 will be added to the invite_friends function, and so on. Here's another code example. You'll notice that we're also tracking an invite friends event in the same function - it's totally OK to do this. You can track as many events as you want.
function invite_friends() {
...
mpmetrics.track('invite friends', { 'num_friends': friends.length, 'id': user_id });
...
mpmetrics.track_funnel('intro skip', 2, 'invite', { 'from': source });
}
Understanding the report
Once we've finished tracking our funnel events, we can check out the data that is being gathered.
We're able to segment this funnel by the source of the user (the 'from' parameter) and see which distribution channel is working out the best for us.
Visitor retention
What should I track?
You don't need to add anything to start tracking visitor retention. We track returning visitors on a per-event basis - so once you're tracking events, you can learn how many of your users come back to interact with them again with no extra effort.
This is the retention data for the mission event. You can see that 4-week retention rates are slowly increasing, from 10.37% retention to 11.14% in the most recent week. This means that 11.14% of the users we saw in the week of December 14 - 20 came back 4 weeks later to do a mission.

Now that you've seen this example, you are ready to check out the integration guides.
