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 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.
Two major steps to be followed to implement Exception Tracking are:
- GTM Configuration
- DataLayer Implementation
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.
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.
- 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.
Push the “exception_occured” event with 2 DataLayer variables from the catch block as shown below:
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:
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!!
Latest posts by Sameer Sanghavi (see all)
- Facebook Ads Install Data Missing in Google Analytics? We are at your rescue - January 19, 2018
- Migrate your website to new host for enhanced Google Analytics Tracking - December 29, 2017
- Google Analytics Real Time Data in Google Sheet - December 23, 2017