여기서 <exception_parameters>는 하나 이상의 매개변수-값 쌍입니다. 각 쌍을 쉼표로 구분하세요. 예를 들어 다음 명령어는 심각하지 않은 오류를 전송합니다.
예외가 인정됩니다.
gtag('event', 'exception', {
'description': 'error_description',
'fatal': false // set to true if the error is fatal
});
예외 매개변수
다음 표에는 예외 매개변수가 나와 있습니다.
매개변수 이름
데이터 유형
필수
설명
description
문자열
아니요
오류에 대한 설명입니다.
fatal
불리언
아니요
오류가 심각한 경우 true입니다.
예
다음 함수가 지정된 경우:
function divide(x, y) {
if (y === 0) {
throw "Division by zero";
}
return x/y;
}
제수 y가 0이면 다음 코드는 Google 애널리틱스로 예외 이벤트를 전송합니다.
var x = document.getElementById('x').value;
var y = document.getElementById('y').value;
try {
var r = divide(x, y);
} catch(err) {
gtag('event', 'exception', {
'description': err,
'fatal': false
});
}
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-09-13(UTC)"],[],["Exception events, used to track web page crashes and errors, are sent to Google Analytics via the `gtag('event', 'exception', {\u003cexception_parameters\u003e});` command. `\u003cexception_parameters\u003e` include 'description' (error details) and 'fatal' (boolean indicating if the error is fatal). When an error is detected, a `gtag` event can be sent. An example uses a `try...catch` block to intercept division-by-zero errors and trigger the `gtag` event.\n"]]