📢 Tatvic is now India’s first certified Conversion Optimization Partner with Google

Google Analytics Exception Tracking Guide for IOS & Android Apps

Last Updated:

Services:    

Google Analytics Exceptions Tracking: Introduction

As an app developer, unexpected production issues can affect your product’s reputation if not resolved quickly.  Suffice it to say, they can ruin your dinner and weekend plans!

Exception Tracking, a method for automatically detecting and responding to exceptions in the target application as they occur, can save you hours (or even days) of troubleshooting! A clear policy on how to track exceptions saves you time in diagnosing, reproducing, and correcting the issues. By using Google Analytics Exception tracking you can spend more time fixing the issue, rather than finding the issue.

This post guides you on how to track exceptions for Android and iOS apps in Google Analytics using Google Tag Manager. After reading this blog, you’ll be able to generate a report called “Crashes and Exceptions” in Google Analytics.

Let’s begin!!
Two major steps to be followed to implement Exception Tracking are:

  • GTM Configuration
  • DataLayer Implementation

GTM Configurations:

The first step includes creating a tag, a trigger, and variables in Google Tag Manager (GTM) Interface. This tag will fire when specified rules are triggered.

Create a GTM tag that fires on “exceptionOccured” trigger.

Note: Tag configuration will be the same for both Android and iOS platforms.

  1. Create 2 variables “exception_description” and “is_fatal” as shown in the following screenshots to collect the exception description and to check whether it is fatal.

Datalayer1
Datalayer2

2. Create a trigger that fires on the custom event called “exception_occured”.

trigger

 

 3. Create a tag with track type “Exception” and add “Exception Description” and “Is Fatal” variables to the same.

tag

DataLayer Implementation:

Once the tag is created in GTM and the container is published, you will need to push a DataLayer snippet from the app. The snippet consists of key-value pairs where the keys are GTM triggers and variables which are defined in the Exception Tracking tag and the values are assigned from the app to specific keys

When an exception occurs in the app, you must be capturing it in the catch block where you’ll also have the description. You’ll need to push a DataLayer from the catch block.

Here’s how it works!

Follow the steps mentioned below to implement the DataLayer snippet in your Android or iOS app.

For Android:

  1. Create a method to push an event and exception to DataLayer.
    datalayer syntax
  2. SetDatalayer event names as “exceptionOccured” & push the two other variables as shown in the above image with the same event.

  3. Call this method (as shown in the below image) inside each catch block of your application.
    calling datalayer push

For iOS:

Push the “exception_occured” event with 2 DataLayer variables from the catch block as shown below:

ios snippet

When the above code executes, you can check that the exception is being sent to Google Analytics in the logs as shown below image.
logs

 

Google Analytics Report Visualization:

Now let’s have a look at the data in Google Analytics.

Open the “Crashes and Exceptions” report by selecting Behaviour -> Crashes and Exception from the left panel in Google Analytics. This report, in a default manner, shows all crashes and exceptions next to app versions.

The GA report will be visible as shown below:

report
So now you can track all of your application’s errors easily and fix them as soon as possible by spending less time finding & more resolving them. 

Google Analytics can also give you different parameters like Mobile Device Brand where these exceptions occur. This will be extremely useful for a developer to regenerate those issues and solve them quickly.

Keep coding. Enjoy 🙂

For any assistance or more details on Exception Tracking, please drop us a message in the comment section below and our experts will be glad to assist you!!

Picture of Jitendra Verma

Jitendra Verma

Jitendra Verma is working as campaign manager in Tatvic. He has been running successful digital marketing campaigns for the top e-commerce giants.

Sign up for
our monthly newsletter

This field is for validation purposes and should be left unchanged.
Scroll to Top

Leverage Tatvic's comprehensive approach to 

Contact Us

Checkbox
This field is for validation purposes and should be left unchanged.