Skip to content

Instantly share code, notes, and snippets.

@ryanmorr
Last active December 28, 2023 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanmorr/630e503f7e26e4aa67f31bd9f55ea325 to your computer and use it in GitHub Desktop.
Save ryanmorr/630e503f7e26e4aa67f31bd9f55ea325 to your computer and use it in GitHub Desktop.
Log an error with Google Analytics 4
function logError(error, fatal = false) {
const description = typeof error === 'string' ? error : error.message;
gtag('event', 'exception', {
description,
fatal
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment