Skip to main content

Error tracking

The Errors tracker plugin provides two ways of tracking exceptions: manual tracking of handled exceptions using trackError and automatic tracking of unhandled exceptions using enableErrorTracking.

Error events can be manually tracked and/or automatically tracked.

Install plugin

Tracker DistributionIncluded


Download from GitHub Releases (Recommended)Github Releases (
Available on jsDelivrjsDelivr (latest)
Available on unpkgunpkg (latest)

Note: The links to the CDNs above point to the current latest version. You should pin to a specific version when integrating this plugin on your website if you are using a third party CDN in production.

["snowplowErrorTracking", "ErrorTrackingPlugin"]

Manual error tracking

Use the trackError method to track handled exceptions (application errors) in your JS code. This is its signature:

snowplow('trackError', {
/** The error message */
message: string;
/** The filename where the error occurred */
filename?: string;
/** The line number which the error occurred on */
lineno?: number;
/** The column number which the error occurred on */
colno?: number;
/** The error object */
error?: Error;
messageYesError messagestring
filenameNoFilename or URLstring
linenoNoLine number of problem code chunknumber
colnoNoColumn number of problem code chunknumber
errorNoJS ErrorEventErrorEvent

Of these arguments, only message is required. Signature of this method defined to match window.onerror callback in modern browsers.

try {
var user = getUser()
} catch(e) {
snowplow('trackError', {
message: 'Cannot get user object',
filename: 'shop.js',
error: e

Using trackError it's assumed that developer knows where errors could happen, which is not often the case. Therefor it's recommended to use enableErrorTracking as it allows you to discover errors that weren't expected.

Automatic error tracking

Use the enableErrorTracking method to track unhandled exceptions (application errors) in your JS code. This is its signature:

snowplow('enableErrorTracking', {
/** A callback which allows on certain errors to be tracked */
filter?: (error: ErrorEvent) => boolean;
/** A callback to dynamically add extra context based on the error */
contextAdder?: (error: ErrorEvent) => Array<SelfDescribingJson>;
/** Context to be added to every error */
context?: Array<SelfDescribingJson>;
filterNoPredicate to filter exceptions(ErrorEvent) => Boolean
contextAdderNoFunction to get dynamic context(ErrorEvent) => Array<SelfDescribingJson>
contextNoAdditional custom contextArray<SelfDescribingJson>

Unlike trackError you need enable error tracking only once:


Application error events are implemented as Snowplow self-describing events. Here is the schema for an application_error event.

Was this page helpful?