Select Page

Mixpanel offers both web and mobile app analytics solution. The strong points for this tool are real-time data, funnel analysis, in-depth analysis to track retention.

Measuring what your users are doing on your application is an important part of the product building process. Because this metrics helps to build an efficient mobile marketing strategy and also know which parts of your app drive valuable conversions.

For using Mixpanel into your application first create an application in your Mixpanel account. Now you got a token using that token only you can connect that Mixpanel application to your mobile application.

After working on the same for many times I thought why not this be done with a single util class. So here it is, my post talking about how to track events with Mixpanel.

MixpanelHelper which is the utility class contains the set of utility methods to connect Mixpanel app and track events.For implementing this just create an instance of that utility class and call the corresponding method with the needed parameter.


MixPanelHelper mixPanelHelper;

mixPanelHelper=new MixPanelHelper(this);

mixPanelHelper.set_profile();

Here events are identified with the name so event name is mandatory and you can send custom attributes for that particular event with the help of JSON object. For adding custom attributes just create a JSONobject and put all the values into it and the pass this object as a parameter.


//Track event with name

mixPanelHelper.triggerEvent("Login");

//Add custom attributes with the events

JSONObject props=new JSONObject();

props.put("$language","English");

mixPanelHelper.triggerEvent("Event2",props);

This util class is available as a Gist over on GitHub if you want to check it out.

View Gist

Feel free to comment and share, keep watching this space get more updates on Android Stuff!

Elsewhere

Jaison Fernando

Android Developer at NFN Labs
Elsewhere