Community Tip: iOS Implementation Roundup
This Community Tip will walk you through implementing Mixpanel in your iOS app. This walkthrough will cover not just how to insert Mixpanel code into your app, but also how to decide what events and properties to track.
Get acquainted with Mixpanel
You heard from your developer friends that Mixpanel is awesome, and you want to see it for yourself. But where to begin? A great place is our Live Introductory Webinar. The Webinar is specially aimed toward new Mixpanel users and it broadly covers Mixpanel’s capabilities, how to think about your analytics, and how to get started with your own data tracking.
Plan your implementation: It starts and ends with your business goals
Mixpanel is a highly customizable data-tracking solution that gives you the power to decide what actions to track and how to track them. With flexibility and power comes great responsibility, and oftentimes it can be overwhelming to get started.
Ask yourself the following questions:
- What are our key business goals?
- What do we want our users to do to reach those business goals?
- How can we measure whether users are doing those actions?
The answer to these questions will help you determine what data to track via Mixpanel. Think about all the members of your team who will be using Mixpanel and what information they need in order to do their job.
Here is an example of how I might apply the process described above to my implementation. Let’s start with our questions:
What are our key business goals?
- Let’s say we have a free music-playing site, and we make money when users listen to songs, because we play ads. Our ultimate business goal is to get users to play more and more songs.
What do we want our users to do to reach those business goals?
- In order to listen to songs, users have to sign up and pick a playlist.
How can we measure whether users are doing those actions?
- We know that it’s important whether users sign up, whether they pick playlists, and whether they play songs. So we could have one event for each of those actions.
Many Mixpanel users like to create an implementation spec to translate their business goals into specific events and properties. Specs also make it easy to keep track of how you are going to track each of your events and what properties go along with each event.
Events and Properties
You should make sure to understand the distinction between events and properties. An event is any meaningful action within your site that you will track in order to gain valuable insight. Properties describe either an event or the user who performed an event. Properties are the building blocks of detailed reports, and taking advantage of properties will allow you get the most value out of your implementation.
Select event names that are simple, action-driven, and easy to understand. ‘Purchase’ is a better name than ‘MXP_1234_XYZ.’ As the project owner, you might understand what ‘MXP_1234_XYZ’ means, but not everyone in your team will have such an easy time.
Further, rather than including specifics in the event name itself, move all details into your properties. If you have an event ‘Registration’ with a property that indicates whether the user registered through Facebook, Google, or Twitter, your data will be easier to aggregate than if you have one event called ‘Facebook Registration,’ one called ‘Google Registration,’ and one called ‘Twitter Registration.’
At this point, you may be wondering what sorts of details you should store in your properties. When in doubt, bring it back to your business questions. What do you want to know about your users that will help you make better product and marketing decisions? A good place to start is to look at the list of properties that Mixpanel registers by default.
The default properties described above are added to every single event fired by your users. You can create your own properties that persist across events. Those are called super properties. Need examples of relevant super properties? This community tip has you covered!
From the function to the form
Now that your whole team has discussed and approved what data you want to track, it’s time to add you code. The following video shows you how to set up the Mixpanel iOS library to start tracking data about your users.
Should you be developing in Apple’s new language for iOS, Swift, you can follow these instructions to implement the Mixpanel iOS library in Swift apps.
Every single event sent to Mixpanel through the iOS library has a distinct_id that helps Mixpanel keep track of unique users within your project. Click here to learn about the many vital uses of distinct_ids.
In the case of iOS, if our library detects that the application is using the AdSupport.framework, we’ll use the IFA (ID for Advertisers) as the distinct_id. For apps that do not serve ads and do not have the AdSupport.framework included, Mixpanel will default to using the IFV (ID for Vendors) as the distinct_id.
A device’s IFA will persist across sessions and app updates unless a user manually resets their advertising identifier within the iOS privacy settings menu. While the IFA remains constant when a user removes and then re-installs the app, the IFV will change with each installation. In either case, by choosing a value which persists as distinct_id, Mixpanel can track the actions of users before they even register.
Furthermore, you have the option of assigning users new distinct_ids by using the identify method or mapping your own database ids or emails to the original user distinct_ids with the createAlias method. Whether or not you should be using these methods will depend on the nature of your registration flow and data tracking implementation. The easiest way to familiarize yourself with Mixpanel’s identity management best practices is to watch the following video.
Last Minute Tips
Once you have added the Mixpanel iOS library to your app, you can give Codeless Mobile Tracking a try! You can visualize your app directly in the UI and select specific elements to track as events. This is a great way to get started with event tracking and see how Mixpanel records the events you decide to track.
Remember: you can track all types of data inside of your properties. Instead of adding lots of events, try to create events which describe main user actions and store the details of that action in the properties.
Diamonds might be a girl’s best friend, but debugging and logging are everyone’s best friend when it comes to implementing Mixpanel on iOS. When you are testing your track calls and making sure alias and identify are working consistently, it helps to have logging enabled to see what the Mixpanel library is doing within your app.
Each of the sections above represents a key aspect of your initial Mixpanel iOS implementation.
What are my business goals? What do I want my users to do?
What events determine whether or not I’m reaching those goals?
What properties will add relevant dimensions to my event data?
Where in my code will I insert the specific calls to track my events?
Am I consistently tracking my users with the appropriate distinct_id values?
If you can answer those questions, then you will be well on your way toward a successful implementation!
Any other questions? Email us at firstname.lastname@example.org to speak with someone smart, quickly.