Exceptional Tracking – An Introduction
As an app developer, unexpected production issues can affect your product’s reputation if not resolved quickly. Suffice 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 from hours (or even days) of troubleshooting! A clear policy on how to track exceptions save your time in diagnosing, reproducing and correcting the issues. By using Google Analytics Exception tracking you can spend more time in 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 which fires on “exceptionOccured” trigger.
Note: Tag configuration will be same for both Android and iOS platform.
- 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.
2. Create a trigger which fires on custom event called “exception_occured”.
3. Create a tag with track type “Exception” and add “Exception Description” and “Is Fatal” variables to the same.
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 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 DataLayer snippet in your Android or iOS app.
For Android:
- Create a method to push an event and exception to DataLayer.
- SetDatalayer event name as “exceptionOccured” & push the two other variables as shown in the above image with the same event.
- Call this method (as shown in the below image) inside each catch block of your application.
For iOS:
Push the “exception_occured” event with 2 DataLayer variables from the catch block as shown below:
When the above code executes, you can check that the exception is being sent to Google Analytics in the logs as shown in below image.
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 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:
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 in resolving.
Google Analytics can also give you different parameters like Mobile Device Brand where these exceptions occur. This will be extremely useful as 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!!

Sameer Sanghavi

Latest posts by Sameer Sanghavi (see all)
- Google Analytics Real Time Data in Google Sheet - November 23, 2021
- Facebook Ads Install Data Missing in Google Analytics? We are at your rescue - November 19, 2021
- Migrate your website to new host for enhanced Google Analytics Tracking - December 29, 2017
7 Comments. Leave new
Thanks a lot for the complete guide. This is really helpful
Great blog very interesting i learned a lot thanks for sharing.
very nice post. KEEP it up
this blog is very helpful for me Thanku for sharing
i am very thankful because you share the beautiful information
Thank You For The Tutorial, really very helpful to me
The information that is provided on your web portal is amazing and I am always eager to catch hold of the new posts being published on your website.