Crash and exception measurement allows you to measure the number and type of handled and unhandled exceptions that occur in your app. An exception in Google Analytics consists of:
- String (Optional) Description – a description of the exception (up to 100 characters). Accepts null.
- Boolean isFatal – indicates whether the exception was fatal. true indicates fatal.
Crash and exception data is available primarily in the Crash and Exceptions report.
Handled exceptions are errors in your app for which you've defined exception handling code. These are generally errors you would anticipate to occur during normal use of your app, and from which you'd like your app to be able to recover, such as the
occasional timeout of a network connection during a request for data.
You can measure handled exceptions by adding SendException() to the catch block of your exception handling code.
In the following example, an app tries to load a list of high scores from the cloud. If the request times out, perhaps due to a slow network connection, we'll send the exception to Google Analytics before handling it for the user:
var highScores = getHighScores(); // Get scores from the cloud.
catch (Exception ex)
Tracker myTracker = EasyTracker.GetTracker(); // Get a reference to tracker.
myTracker.SendException(ex.Message, false); // false indicates non-fatal exception.
... // Display alert to user that high scores are currently unavailable.
Unhandled Exception Measurement
Unhandled exceptions represent instances where your app encountered unexpected conditions at runtime and are often fatal, causing the app to crash as a result. Unhandled exceptions can be sent to Google Analytics automatically by using EasyTracker or manually
catching and reporting exceptions via Tracker.SendException(...).
To automatically send all uncaught exceptions in your app using EasyTracker, add this line to your analytics.xml file:
After sending an exception using automatic exception measurement, EasyTracker will pass the exception on to the default unhandled exception handler.
When using automatic exception measurement, keep in mind the following:
- All exceptions sent using automatic exception measurement are reported as fatal in Google Analytics.
- The description field is automatically populated using the stack trace.
Manually reporting exceptions
Simply add an event handler to the Application's UnhandledException event and from within it, call myTracker.SendException(description, isFatal).