How to track your program's exceptions via Google Analytics

In the release v.0.5.6 of our desktop software analytics library, we added the ability to remotely track your program's exceptions in Google Analytics.

When an exception is caught in your program, instead of just logging it locally, you can additionally call latSendException() to send the incident and its details to your Google Analytics property.

From there, you can remotely monitor how your application runs and what kind (if any) of exceptions it throws.

By monitoring other parameters like the OS version or the screen resolution, you can understand if there are platform parameters that trigger the exception and understand the reason behind it.

This powerful view of what is failing at the users' computers, will enable you to quickly fix any errors, even before your users report them back to you.

Software exception catching and reporting via Google Analytics
Example report in Google Analytics showing the application's crashes and exceptions.

To see the application crash and exception report, go to:

  • your Google Analytics property ->
    • Behaviour ->
      • Crashes and exceptions

As always, the reporting is at the level of "reporting view" in your Google Analytics account. For the "Crashes and exceptions" menu to be there, your reporting view must be of the "Mobile App" type. If you do not already have a "Mobile App" view, create a new one.

Below is a C/C++ source code example (part of the cpp-demo-main.cpp) showing how you can send application's crashes and exceptions to Google Analytics.

// And now, some exception handling....
// ---------------------------------------
try
{
	throw std::runtime_error("TEST THROW c++ exception"); // Emulate a C++ exception
	std::cout << "try {} block completed without exceptions thrown" << std::endl;
}
// Notes about the C++ try..catch statements
// Some things are called exceptions, but they are system (or processor) errors and not C++ exceptions.
// The following catch block only catches C++ exceptions from throw, not any other kind of exceptions (e.g. null-pointer access)
// In any case, if you manage to catch the exception or the system error, you can then use latSendException() to send it to Google Analytics
catch (const std::exception& ex)
{
	std::cout << "Exception caught; will send it to G.A." << std::endl;
	std::string excDesc("Error #18471a in " __FILE__ ": ");
	excDesc += ex.what();
	if (!telemetryDll.latSendException(excDesc.c_str(), 0))
	{
		std::cerr << "Error calling latSendException\n";
		return 205;
	}
}
catch (...)
{
	std::cout << "Exception caught; will send it to G.A." << std::endl;
	if (!telemetryDll.latSendException("Error #18471b in " __FILE__, 0))
	{
		std::cerr << "Error calling latSendException\n";
		return 206;
	}
}

 

Comments

This is outdated. In the new version of google analytics, I can't find a way to see those exceptions reports.

SoftMeter works with the "Universal Analytics" version of Google Analytics. Under your GA account, you must create a "Universal Analytics" property of type "Application monitoring" and send the hits from your application to that propertyID. There, the "Crashes and Exceptions" report exists by default under the "Behaviour" menu.

Application crashes and exceptions remote tracking and reporting via Google Analytics

Alternatively, you can create a custom report to view the "Crashes and Exceptions"  hits.

Add new comment