Reader small image

You're reading from  Getting Started with Flurry Analytics

Product typeBook
Published inDec 2013
Reading LevelIntermediate
PublisherPackt
ISBN-139781782177128
Edition1st Edition
Languages
Right arrow
Author (1)
Bhanu Birani
Bhanu Birani
author image
Bhanu Birani

Bhanu Birani has more than 7 years of experience in the software industry. He is passionate about architecting, designing, and developing complicated applications. He specializes in creating web, backend as a service, and mobile products suitable for B2B and B2C context. He has expertise in end to end development to create innovative and engaging applications for mobile devices. After years of programming experience in different programming languages, he started developing applications for iOS devices. He started software development around the same time as his graduation and was really interested in learning about the new technologies emerging in the market. He then joined a game development company. After contributing to the gaming domain, he started working on content-based applications and radio applications. He also contributed to hyperlocal geo-targeting using BLE (iBeacons). Over the years, he has gained experience in all phases of software development as requirement gathering, feasibility analysis, architecture design, coding and debugging, quality improvement, deployment, and maintenance.
Read more about Bhanu Birani

Right arrow

Chapter 2. Tracking Applications

This chapter explores various ways to track your application using Flurry. This application provides advanced ways to track applications in order to generate useful data. If you want to know which device your application is accessed on the most or know the age group of the users who are using the application the most. In this chapter, we will learn to track the application specifying the parameters that will help us to provide filters for the generated and gathered data.

Also, we will learn about the following in detail:

  • Ways to set up goals to track your application

  • Tracking time spent by users on the application

  • Module-based application tracking

  • Tracking specific versions of the application

Settings goals


In the previous chapter, we learnt about setting up and installing Flurry in your project. In this chapter, we will track an application and its specific sections using goals to generate detailed reports. Your goals will vary depending on your requirements for the data you want to gather from your application. So Flurry provides you with a way to track all your events using your event ID.

You can use the following code to track the event:

[Flurry logEvent:@"EVENT_NAME"];

The logEvent: method logs your event every time it's triggered during the application session. This method helps you to track how often that event is triggered. You can track up to 300 different event IDs. However, the length of each event ID should be less than 255 characters.

After the event is triggered, you can track that event from your Flurry dashboard. As is explained in the following screenshot, your events will be listed in the Events section. After clicking on Event Summary, you can see a list of the...

Tracking time spent


Flurry allows you to track events based on the duration factor as well. You can use the [Flurry logEvent: timed:] method to log your event in time as shown in the following code:

[Flurry logEvent:@"EVENT_NAME" timed:YES];

In case you want to pass additional parameters along with the event name, you can use the following type of the logEvent: method to start a timed event for event Parameters as shown in the following code:

  [Flurry logEvent:@"EVENT_NAME" withParameters:YOUR_NSDictionary timed:YES];

The aforementioned method can help you to track your timed event along with the dynamic data provided in the dictionary format.

You can end all your timed events before the application exits. This can even be accomplished by updating the event with event Parameters. If you want to end your events without updating the parameters, you can pass nil as the parameters.

If you do not end your events, they will automatically end when the application exits as shown in the following code...

Tracking errors


Flurry provides you with a method to track errors as well. You can use the following methods to track errors on Flurry:

  [Flurry logError:@"ERROR_NAME" message:@"ERROR_MESSAGE" exception:e];

You can track exceptions and errors that occurred in the application by providing the name of the error (ERROR_NAME) along with the messages, such as ERROR_MESSAGE, with an exception object. Flurry reports the first ten errors in each session.

You can fetch all the application exceptions and specifically uncaught exceptions on Flurry. You can use the logError:message:exception: class method to catch all the uncaught exceptions. These exceptions will be logged in Flurry in the Error section, which is accessible on the Flurry dashboard:

// Uncaught Exception Handler - sent through Flurry.
void uncaughtExceptionHandler(NSException *exception) {
  [Flurry logError:@"Uncaught" message:@"Crash" exception:exception];
}

- (void)applicationDidFinishLaunching:(UIApplication *)application 
 {
 NSSetUncaughtExceptionHandler...

Tracking versions


When you develop applications for mobile devices, it's obvious that you will evolve your application at every stage, pushing the latest updates for the application, which creates a new version of the application on the application store. To track the application based on these versions, you need to set up the Flurry to track your application versions as well. This can be done using the following code:

[Flurry setAppVersion:App_Version_Number];

So by using the aforementioned method, you can track your application based on its version. For example, if you have released an application and unfortunately it's having a critical bug, then you can track your application based on the current version and the errors that are tracked by Flurry from the application.

You can access data generated from Flurry's Dashboards by navigating to Flurry Classic. This will, by default, load a time-based graph of the application session for all versions. However, you can access the user session graph...

User details


Flurry provides many methods to track users based on their information. For example, if you need to track the user based on their ID, you can use the following code:

[Flurry setUserID:@"USER_ID"];

Note that as per the terms of service, you are not allowed to pass the Unique Device ID (UDID) of the device as a parameter in this method.

After identifying the user based on their ID, you can use the following method to track their age (the input parameter should be greater than 0).

[Flurry setAge:23];

After tracking the user's age, you can access the data generated by Flurry to analyze the age group of the users who use the application the most, as shown in the following screenshot:

To identify the gender of the user, you can use the following method:

[Flurry setGender:@"m"];

The preceding code takes either m for male or f for female to specify the gender. After tracking the user's gender through the application, you can access the application's generated data through Flurry. You can navigate...

Location tracking


You can fetch the user's location by using the CCLocationManager class. The following code will start to get the current location of the user. However, to track a user's location, you need to add CoreLocation.framework in your project to track the location of a user in Flurry as shown:

  CLLocationManager *locationManager = [[CLLocationManager alloc] init];
  [locationManager startUpdatingLocation];

After getting the location, you can set the location in Flurry. You can set CCLocationManagerDelegate to get the callback when the updated location is received. Once the updated location is received from the locationManager class, you can use the following method to set the same on Flurry:

  CLLocation *location = locationManager.location;
  [Flurry setLatitude:location.coordinate.latitudelongitude:location.coordinate.longitudehorizontalAccuracy:location.horizontalAccuracyverticalAccuracy:location.verticalAccuracy];

The preceding method will update the user's current GPS location...

Controlling data


You can control your data submission on Flurry using various methods provided by them. The following method allows Flurry to send session data when the application is closed or when the application is started:

  [Flurry setSessionReportsOnCloseEnabled:(BOOL)sendSessionReportsOnClose];

This method is set to YES by default and will improve the speed at which your application analytics data is updated on Flurry. It will prolong the termination process of the application because of network latency:

[Flurry setSessionReportsOnPauseEnabled:

This method is also set to the YES option by default. When this function is set as YES, Flurry will try to send the data when the application is in the pause mode. Normally when the application is started, Flurry will try to send the data generated. This is will improve the speed of updating data on Flurry.

  [Flurry setSecureTransportEnabled:(BOOL)secureTransport];

The preceding method is used to transport your data securely to Flurry. This method...

Summary


In this chapter, we explored the ways to track the application on Flurry and to gather meaningful data on Flurry. We started by setting goals to track the application. Then we learned how to track the time spent by users on the application along using user data tracking. Then we learned location-based tracking to track the application usage based on location. Finally, we learned how to control the data generated by the Flurry application.

In the next chapter, we will learn about the ways to analyze the data generated by Flurry.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Getting Started with Flurry Analytics
Published in: Dec 2013Publisher: PacktISBN-13: 9781782177128
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Bhanu Birani

Bhanu Birani has more than 7 years of experience in the software industry. He is passionate about architecting, designing, and developing complicated applications. He specializes in creating web, backend as a service, and mobile products suitable for B2B and B2C context. He has expertise in end to end development to create innovative and engaging applications for mobile devices. After years of programming experience in different programming languages, he started developing applications for iOS devices. He started software development around the same time as his graduation and was really interested in learning about the new technologies emerging in the market. He then joined a game development company. After contributing to the gaming domain, he started working on content-based applications and radio applications. He also contributed to hyperlocal geo-targeting using BLE (iBeacons). Over the years, he has gained experience in all phases of software development as requirement gathering, feasibility analysis, architecture design, coding and debugging, quality improvement, deployment, and maintenance.
Read more about Bhanu Birani