Universal Analytics (UA) will be deprecated on July 1, 2023, which means it will stop processing data. Analytics 360 properties will stop working on October 1, 2023. Migrate to Google Analytics 4.

Exception Tracking

Stay organized with collections Save and categorize content based on your preferences.

This guide describes how to send exceptions using analytics.js. Exception tracking allows you to measure the number and type of crashes or errors that occur on your property.

Implementation

Exception hits can be sent using the send command and specifying a hitType of exception. The send command has the following signature for the exception hit type:

ga('send', 'exception', [fieldsObject]);

Exception fields

The following table summarizes the exception fields:

Field Name Value Type Required Description
exDescription text no A description of the exception.
exFatal boolean no true if the exception was fatal.

Example

The following command wraps some logic that may fail in a try/catch block. If there's an error, it sends an exception hit to Google Analytics:

try {
  // Runs code that may or may not work.
  window.possiblyUndefinedFunction();
} catch(err) {
  ga('send', 'exception', {
    'exDescription': err.message,
    'exFatal': false
  });
}