Start a Project

How to track your android app “Exceptions and Crashes” by google analytics v4 Chapter-2

This is chapter-2 of “how to track your android application by GAv4″.
In this chapter,
I will show you how to track exception and crashes by GAv4.

Exception: An exception is a computational problem that occurs when any program executes. When an Exception occurs the normal flow of the program is an interrupt and the Application terminates abnormally.

Application Crashes: A Application crash is when a program of application stops functioning properly. Often it will exit the affected program after encountering this type of error.

If you are an app developer obviously your app will be used by many people, from many states and by many countries. And by some reason, the app crashes or got an exception then how do you know. And this is the major issue to track our app that when to get exception/crashes and wherein entire app.

So, For resolving that problem google analytics give us the method for tracking exceptions/crashes of your application.

How to track Exceptions

By analytics, any Exceptions can also be tracked very easily. It permits us to track all the known exception which we tried to catch using try & catch block.

and in your application class use this method.

How to Track App Crashes

App crash recorded automatically by setting ga_reportUncaughtExceptions to true in app_tracker.xml.

Actually, we have to make our own app_tracker.xml  file and replace it to the default global_tracker.xml

This is auto-generated XML file by analytics.

global_tracker.xml

to override default tracker file

make our tracker XML file in app -> res -> xml package

app_tracker.xml

ga_autoActivityTracking: If true, views (Activities) will be tracked automatically.

ga_reportUncaughtExceptions: Automatically track an Exception each time an uncaught exception is thrown in your application.

For more details about google parameters: goto the Google Analytics SDK v4 for Android – Parameters

And on the place of global_tracker.xml 

write our app_tracker.xml file

App crash will be recorded and will be shown on Google Analytics dashboard.

Goto Behaviour -> Crashes and Exceptions section on the dashboard.

Both the Exception and app crash report normally takes 1 day to reflect on Google Analytics dashboard.

In above snapshot, I have intensely crashed my application in MainActivity.

And Analytics dashboard shows the report of crashes and exception.

Sources:

developers.google.com/analytics/

Previous Chapter

Exit mobile version