iOS Implementation

This article shows you how to implement Mixpanel in your iOS app.

Specifically, this guide covers how to insert Mixpanel code into your app, and how to decide what events and properties to track.

Use Your Business Goals to Plan Your Implementation

Mixpanel is a highly customizable data-tracking solution that gives you the power to decide what actions to track and how to track them.

Before you implement Mixpanel. Ask yourself these questions:

  1. What are your key business goals?
  2. What do you want users to do to reach your business goals?
  3. How can you measure whether users are doing those actions?

The answer to these questions helps you determine what data to track with Mixpanel. Think about all the members of your team who will be using Mixpanel and what information they need to do their job.

Applying the Process

Here is an example of how to apply the questions posed above.

What are your key business goals?

  • Let’s say you have a free music-playing site, and you make money when users listen to songs when they play ads. The ultimate business goal is for users to play more songs.

What do you want your users to do to reach those business goals?

  • 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 plan to translate their business goals into specific events and properties.

Implementation plans also tracks how you are going to track each of your events and what properties to append to each event. For more information, see Plan Your Implementation.

Reviewing the Purpose of Events and Properties

An event is any meaningful action in your site that you track to gain valuable insight.

An event property describes an event, and a people property describes the user who performed an event.

Properties are the building blocks of detailed reports.

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.

Use properties to add details to an event.

If you have an event "Registration" with a property that indicates whether the user registered through Facebook, Google, or Twitter, your data is easier to aggregate than if you name the event ‘Facebook Registration,’ another as ‘Google Registration,’ and one named ‘Twitter Registration.’

At this point, you might wonder what sorts of details you should store in your properties. When in doubt, remember 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 the list of properties that Mixpanel registers by default. The default properties described above are added to every single event your users fire. You can create your own properties to persist across events. Those properties are super properties.

Adding Tracking Code

Now that your whole team has discussed and approved what data you want to track, it’s time to add your code. This video shows you how to set up the Mixpanel iOS library to track data about your users.

If you don’t want to integrate the library using CocoaPods, you can install the library manually from source. Remember to import all necessary dependencies when you install manually.

If you’re developing with Swift, follow these instructions to implement the Mixpanel iOS library in Swift apps.

Using Identity Management in Event Tracking

Each event sent to Mixpanel through the iOS library has a distinct_id that helps Mixpanel track unique users in your project.

If the Mixpanel library detects that the application is using the AdSupport.framework, you should use the IFA (ID for Advertisers) as the distinct_id. For apps that do not serve ads and do not have the AdSupport.framework, Mixpanel defaults to IFV (ID for Vendors) as the distinct_id.

A device’s IFA persists across sessions and app updates, unless a user manually resets the advertising identifier in the iOS privacy settings menu.

While the IFA remains constant when a user removes and then re-installs the app, the IFV changes with each installation. In either case, when you choose a value that persists as distinct_id, Mixpanel can track the actions of users before they register.

Furthermore, you have the option to assign users new distinct_ids with the identify method or map your own database ids or emails to the original user distinct_ids with the createAlias method.

Whether you should use these methods depends 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 video below.

Note that the video describes identity management in relation to Mixpanel’s JavaScript library. The only difference in iOS is when you call createAlias upon signup, you need to call identify with the original distinct_id value.
 

After you add the Mixpanel iOS library to your app, you can try codeless mobile tracking. You can visualize your app directly in the UI and select specific elements to track as events.

Codeless mobile tracking is a great way to track events and see how Mixpanel records the events track.

Remember, you can track all types of data inside of your properties. Instead of adding many events, try to create events that describe main user actions, and store the details of that action in the properties.

Debugging and logging is helpful when implementing Mixpanel on iOS.

When you test your track calls and ensure alias and identify work consistently, it helps to see the logging information about the Mixpanel library in your app.

Is this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.