Android Articles
Homepage | Tutorials | Blog



Mixpanel for Android App Free Analytics

Mixpanel, How To Utilize Their Metrics
Android Apps

added Oct, 2023

Who Is Mixpanel

Mixpanel is an online website that has a comprehensive and unique analytics platform you can use to get metrics about the performance of your Android app.

They offer both a free and paid version, with the free version having a sleuth of options you can use to to gather data points about your apps users. With engagement, retention, lifecycle, cohorts, and live events, you can gather a variety of important information to see what users are doing in your app and how they are doing it. Specifically, you can add custom events to see where users travel in your app and where they spend the most time. These custom events can be added to monitor a page, a video, an action taken, or even collecting data like an email.
The Mixpanel free version lets you analyze data for 20 million events per month, which is great for any new app with little or a lot of downloads. As your business grows, you can add more events. For about $20 per month you get 100 million events. Mixpanel free version is free to join with no credit card required.

Mixpanel Integration

This tutorial discusses implementing the code for a simple one page Android app. For more complex integrations, read the well written documentation at the Mixpanel website for Android.

In order to use Mixpanel Analytics in your Android app, you must add their integration code for the Android mobile platform. Their website has 'set up Mixpanel' guides, you can read to add different codes depending on what events or data points you intend to gather in your app.
For the basic one page app mobile implementation for Android apps, you just need to place a few lines of code at the java class, build gradle, and manifest files in your app project, then simply run your app. Then the app connects to the Mixpanel servers, and then starts collecting data for your app which you can view in your Mixpanel account. Once your app is connected, in your account at settings, you'll see 'data connected'. This means your app is now ready to collect data from users who download and use your app. Also, you can view 'live events', which is upto the minute reporting of all your apps and app events.

Mixpanel Data Connected

Get Started, Join Mixpanel

To get started with the free version of Mixpanel, goto their website, Mixpanel website , and select the Get Started button to join. Add your info then you goto your Mixpanel account. Firstly, add your organization name. This can be your business name or simply your website name. This can also be edited later if need be. To add the organization name, select the Settings Round Icon, top right of page, and then click Organization Settings Add your info - create, save as required.
Mixpanel add your organization

Next, you add your first app name; again from top right side of page, select the 'All Project Data', menu, then at bottom click 'Create Project'. Fill in your Apps Name, select a data center, USA or Europe, select your timezone, and your organization name. If you only added one organization it is selected for you by default. Next, select save, and your new app profile is created.

For our example here; this image shows 2 created apps - App Metrics and Tankies Wildlife. Since App Metrics is selected it shows at the top Menu - All Project Data
Create Project
Next, we get the 'token' number. This is required for the integration and goes into the code. The token itself is a bunch of numbers that creates a long number; that you paste into the integration code where it says 'add_token_here'. To get this info, goto right top side page at Project Data, select the app name you just created. Once selected, it should show at the top menu at 'All Project Data', as shown in the image example.
Next, click on the settings round icon,(top right side page) and then select 'Project Setting'. This will show the project settings page for your selected app, which is the new app name you just added. Here you can view your token number for that app. The 'Project Token', is what you need to copy, and add to the integration code.

Mixpanel Integration Token for Android app


Integration Code for Mixpanel

Once you have joined Mixpanel (free or paid version), added your organization, and added your first app name, the next step is to add the code to your apps' code to implement the analytics. As mentioned, you have to copy the 'token' for the app you want to add the Mixpanel Analytics integration to. Once you copy your token, simply follow the procedure as outlined in these images, to add it to your app code. You can also copy the code from the Example Code section at the bottom of this page, and paste it into your app code.

For this simple, one page app integration, the code is added to the MainActivity.java, manifest.xml, and buildgradle files in your Android app project. For this Mixpanel integration tutorial, we assume you have knowledge of coding an Android app using AIDE. If not, you can follow along with our Android App tutorials to learn how to make your first Android app .


Mixpanel Code for Class and Import Code
In your MainActivity.java you will add three different lines of code; one at the imports for the Mixpanel import statement, one for the mixpanel variable(we have to create the mixpanel variable), and one at the create method(here we refer to the variable we created and create an instance of it). The create method line of code is where you add your Mixpanel 'token'.
Next, At build gradle you add the Mixpanel dependency code or library code as it is also known.

Mixpanel Integration code for Dependencies

And, lastly, at androidmanifest.xml, we add the permissions in three lines, with the Internet permission, the Access Network State permission, and the Access WIFI permission.

Mixpanel Integration code for Manifest

Tips

Make sure you are on the internet so you can connect to the Mixpanel servers once you have added your code and run your app to complete the setup process. If your not live,(online), you cannot see your live events, until you do go online.
Just follow the arrows in these images to see where to place the code. To simplify coding, you can copy and paste the code from our Example Code section on this page.
If your app has several screens,(more than one), you will have to add additional tracking code to track those pages which you can get at 'Mixpanel Setup', to do so, click on Settings, then select Mixpanel setup, once logged into your Mixpanel account.


This Mixpanel integration is for a basic simple integration, which allows you:
to view your app downloads,
keep track of active users: daily, weekly, monthly,
and, keep tabs on retention of users, including those who leave but then return to use your app.
You can also view live Events, which is basically live reporting of your users and your stats. Additionally, cohorts can be set up, and you can view a sleuth of other data that is automatically collected by Mixpanel.

Mixpanel View Data

To keep it simple, you get to view all those users who download your app(with distinct ids for each unqiue app download as shown in this image), and sessions completed per each unique user. This also includes the time they spend in your app. Once time passes, you can then add conditions to compare users, and what and where they go in your app for what length of time. This is great for comparing pages in our app; to see which ones are more popular with your users. And, you can compare users by where they live, including their country, and their phone make.

Basic Reporting by Mixpanel - Sessions, Value Moments

With this Mixpanel integration code, basic reports(events) are tracked automatically by Mixpanel. Some of the events that track automatically and segmented by criteria are: new users, first session, last session, first app open, time of session, active user(dau,wau,mau), dormant users, reinstated users(were dormant) country, city, cellphone make, cellphone model, and more.

With Mixpanel, an event is a session, and a session is an event, for the sake of reporting. And, a 'value moment' can also be an event or a session. A value moment is something you define as being important to track. A session can be simple like when a user uses your app - 'start session', or perhaps 'end of session' when user stops using your app for the day.

A value moment can be a custom event you create or it can be an automatic event you define as your value moment like 'session start' for a particular user.
A value moment custom made event could be when a user watches a 'short video' you added to your app, or perhaps a particular group of users who watched the video on a specific day or within a certain timeframe. It's a value moment because you defined it as important and you want to track it to see if your users interact with it. Then, you can compare that interaction with another interaction to see which one gets more user engagement over a selected time frame. Now you see the value in adding custom events and defining 'value moments'.

If you app sells products or services, then selling a certain product could be a 'value moment'; or when so many units are bought within a week, or on a certain day. And, once you have comparable data, you can track a group of users, or user sales from a specific country to compare sales trends.

Mixpanel Chart Types

Mixpanel has numerous charts you can select to view your collected data like: insights, funnels, retention, engagement, flows, and more. To view these, select 'Reports', from top left of the menu bar.

Mixpanel Chart Types to Use

You can also add a New Board and add a report to it, either from creating your own or choose from the templates available, which include a variety of reports all in one. To select a Board, from the top left of page, select Board, then New Board to get started.

Mixpanel Boards for Reporting Stats

Then choose 'add a board', or select use a 'template'.

Mixpanel Select Template

Next, for a template report, select 'Use a template' to view reports. Then, choose the 'Lifecycle Cohort Analysis Report'(shown in this next image), and then select 'Start from Template', then select an event, just select 'App Session'. With Mixpanel automatic event tracking you will see 'app session', 'app start', 'app first open', 'end session', or 'any event', as your choices to track for data collection.
If however, you had created custom events, then those would show here also and you could select any of those. But for our automatic event reporting we will just select 'app session'. And, then select 'Create'. Your reports are now created for you to view.

Mixpanel Select Lifecycle Chart

With automatic event tracking, you can gather a lot of info about your app users, including; their time spent in your app, the days they returned to use your app, total time they have been an active user of our app, and of course retention. If they stop using your app, and then return another day to continue using it, you can view that data as well. As well, you can view total number of users, with metrics for users from different countries and regions, and even cell phone make and models.

This chart show all your active users, meaning those that are still actively using your app.

Mixpanel Marketing KPI Active & New Users

This next report is your 'live events'(live preview), which you can view by selecting 'Events' from your top menu bar, once you are logged into your Mixpanel account. This report updates by the minute, so it shows, each and every active user who is at the moment using your app, and for hours previously. You can identify each unique user by looking at the 'distinct id' column. Each cell phone is a different distinct number, and each has a distinct color code as well, making it easy to identify the unique users.

Mixpanel Live Preview, Events

In Summary

The Mixpanel Android app integration is easy to implement for automatic tracking of events. You can gather data points about your active app users including where they navigate in your app, and the time they spend using your app. App sessions are the most basic method of tracking your users, while still collecting some very useful information.

New Users and returned users can be monitored as well. With Live Events, you can see realtime user interactions. And, with total active users, you can compare those users who stayed with your app to those who returned at a later time. Many chart types are available for data reporting; and these can be saved for future analysis.

The free version of Mixpanel has tons of useful charts and data reports that are great for a new app start allowing you to get meaningful data points about your users and their engagement with your app.

Learn more about Mixpanel by reading the documents at, Settings - select, 'setup Mixpanel'. You can customize your data collecting by adding your own customized events, and gather additional insights about your users by implementing cohorts with a variety of Mixpanel metrics.


EXAMPLE CODE For Mixpanel Integration

JUST copy the code for this tutorial from the Example Code in this section, then paste it into your app code.

Example Code:
Copy Paste the Code





YOU MAY LIKE:

Websites - Free Analytics for Android
Taste World Wines - Free Wine App

Learn Spanish Free
With Audios

APPBRAIN
Android Support Library Stats

Android AdNetwork Stats

Photos Courtesy of Pixabay, Pexels, Freepik
Credits GoHere


AndroidAppCoding.com - All Rights Reserved.
All images posted on this Website are Copyrighted © Material.