Funnel Analysis

How to track funnels with Mixpanel

Funnel Analysis allows you to increase conversions for any goal you have in mind by quickly identifying problem areas in your application's flow. For a more in-depth explanation about what funnel analysis is and why it's useful please check out our blog post: Introduction to analytics - Funnel Analysis

There are two ways to create funnels: one using events, and one that requires you to make API calls to Mixpanel for each funnel step:

Creating new funnels with your events


It's now possible to create new funnels based on the events you're already tracking. Instead of having to write separate code for your funnels, you can just scatter event tracking calls throughout the system and then build funnels from the raw events.

This is the preferred method for creating new funnels.

How It Works

Once you create a new funnel, we immediately start matching your events with the funnel steps. You'll start seeing data immediately, and all future data will be recorded.

Creating A New Funnel

When creating a new funnel, the first thing to do is figure out which events should be funnel steps. Once we have that figured out, we can put them in the right order and save the funnel. We do this with the Funnel Builder interface:

You can access the Funnel Builder from your Funnel Overview page - just click the button at the top of the page.

Then you just have to select the events that make up your funnel. This is easy - simply click the event name to select it for a step. You can change or remove steps at any time.

After picking your steps, click Preview and name your funnel. Then you can save the funnel and we will start recording data immediately.

Funnels built this way are a little different than the funnels you're used to - because we know in advance what your steps are, we can show you a basic version of the funnel even before you have any data. Here's what the Funnel Overview page looks like after we create a funnel: You can click through and see the funnel report, even if you don't have any data yet.

Advanced usage

One thing to be aware of while using the Funnel Builder is how properties work. The properties you send with each event will be treated just like normal, but this may have a slight impact on the way you use Super Properties.

We encourage everyone to use Super Properties whenever possible, especially for funnel analysis, but you will no longer be able to specify Super Properties that are only registered for funnels. You will need to register them for events, so that they will be included with your event data.

This will probably not be an issue, but if it is the change is very simple:

// Go from this:
mpmetrics.register({'version': 'A'}, 'funnels');

// to this (registered for all)
mpmetrics.register({'version': 'A'});
// or this (registered for events only)
mpmetrics.register({'version': 'A'}, 'events');

Tracking funnels directly


It's also possible to send funnel-specific tracking calls instead of using events. It requires one line of code per funnel step. Here's an overview of the funnel tracking function and its arguments:

mpmetrics.track_funnel(funnel, step, goal, properties, callback)

The description of these are as follows:

  • funnel is the name of the funnel you wish to track, it can be anything.
  • step is position in the funnel, you must start at 1 and can go up to 255. Mixpanel expects consecutive steps, users will not be counted if they go from step 1 to 3 in step 3. Our service will check to make sure the user was seen in previous steps before counting them and only counts unique visitors.
  • goal is the name of what you're tracking at a certain step. Goals must stay the same per step. We do not track multiple goals for a single step at this time.
  • properties are an object map (or dictionary) that are exactly like properties in normal event tracking. Properties will let you segment users between funnel steps.

For the funnel to function, you must include a distinct_id or an ip with the request. If you are making an AJAX request, we will pull the ip from there.

Please note, user data is rejected for Step n if the user was not seen in Step n-1 (previous step) where n > 1 (i.e. skipping steps is not allowed). Visitors may repeat steps however they will only be counted once.

You are expected to include our Javascript library just like normal event tracking. A Facebook one is available as well.

Real example


// If you haven't done so already, include the Javascript library on your page:

<script type="text/javascript" src="http://api.mixpanel.com/site_media/js/api/mixpanel.js"></script>
<script type="text/javascript">
try { var mpmetrics = new MixpanelLib("YOUR_TOKEN"); } catch(err) {}
</script>

// Then, you can begin logging funnel data: 

// Step 1:
mpmetrics.track_funnel("Ticket Purchasing", 1, "Impression");
// Step 2:
mpmetrics.track_funnel("Ticket Purchasing", 2, "Lead");

In step 1, we are tracking when the user lands on the first page of our ticket selling website, so we count the impression. In step 2, we are tracking when the user buys a ticket. You simply include each line in the relevant part of your code - step 1 on page load, and step 2 when they add their information via a form. Your funnel can easily span your entire website, as each step is fired by the relevant event.

Advanced example with properties


Properties really differentiate our funnel analysis tool from the rest because they allow you to segment users between steps. Imagine you knew the gender of your users and wanted to track how gender affects a user from step 1 to step 2 of your funnel, we can do this.

Example

Step 1: mpmetrics.track_funnel("Ticket Purchasing", 1, "Impression", {"gender" : "male"});
Step 2: mpmetrics.track_funnel("Ticket Purchasing", 2, "Lead", {"gender" : "male"});

Just like event tracking you're welcome to use as many as you want and are allowed to track whatever you want. You can easily extend this to tracking the performance of an ad-campaign and the like. Our service will automatically do the analysis in real-time.

Example screenshot of our funnel