Google 애널리틱스 측정 프로토콜은 이벤트의 형식이 잘못되었거나 필수 매개변수가 누락된 경우에도 HTTP 오류 코드를 반환하지 않습니다. 이벤트가 유효한지 확인하려면 이를 프로덕션에 배포하기 전에 측정 프로토콜 유효성 검사 서버를 테스트해야 합니다.
이벤트가 올바르게 구성되었음을 확인한 후에는 올바른 키를 사용하고 있는지
검증하기 위해 구현을 확인해야 합니다.
유효성 검사 서버를 직접 호출하거나 Google 애널리틱스 이벤트 빌더를 사용할 수 있습니다. Google 애널리틱스 이벤트 빌더를 사용하면 이벤트를 양방향으로 구성할 수 있습니다.
또한 Google 애널리틱스 이벤트 빌더는 측정 프로토콜 유효성 검사 서버를 사용하여 구성된 이벤트를 검사합니다.
이 가이드에서는 Google 애널리틱스 4 유효성 검사 서버의 측정 프로토콜로 이벤트를 전송하고 응답을 해석하는 방법을 설명합니다.
유효성 검사를 위해 이벤트 전송
측정 프로토콜로 전송된 이벤트와 측정 프로토콜 유효성 검사 서버로 전송된 이벤트 요청의
유일한 차이점은 URL입니다.
서버
URL
측정 프로토콜
/mp/collect
측정 프로토콜 유효성 검사 서버
/debug/mp/collect
다른 모든 요청 필드는 동일하며, 프로토콜 참조에서 유효한 요청을 작성하는 방법에 대한
자세한 내용을 참고하세요.
다음 코드에서는 측정 프로토콜 유효성 검사 서버로 전송된 잘못된 이벤트를 보여줍니다.
유효성 검사 응답
이전 이벤트에 대한 유효성 검사 서버의 응답은 다음과 같습니다.
{"validationMessages":[{"fieldPath":"events","description":"Event at index: [0] has invalid name [_badEventName]. Names must start with an alphabetic character.","validationCode":"NAME_INVALID"}]}
[null,null,["최종 업데이트: 2025-08-26(UTC)"],[[["\u003cp\u003eThe Measurement Protocol Validation Server helps ensure your Google Analytics 4 events are correctly formatted before deploying to production.\u003c/p\u003e\n"],["\u003cp\u003eThe Validation Server uses a different URL endpoint (\u003ccode\u003e/debug/mp/collect\u003c/code\u003e) than the standard Measurement Protocol (\u003ccode\u003e/mp/collect\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eValidation responses provide detailed error messages including the field path, description, and a validation code for easier debugging.\u003c/p\u003e\n"],["\u003cp\u003eEvents sent to the Validation Server are not processed and will not appear in your Google Analytics reports.\u003c/p\u003e\n"],["\u003cp\u003eThe Google Analytics Event Builder offers an interactive way to construct and validate events before sending them to the server.\u003c/p\u003e\n"]]],["To ensure valid events, use the Measurement Protocol Validation Server by sending requests to `/debug/mp/collect` instead of `/mp/collect`. Validate events before deploying them. This server doesn't log events in reports. It returns a response with `validationMessages`, an array detailing any errors like `NAME_INVALID`, `VALUE_REQUIRED`, or `VALUE_OUT_OF_BOUNDS`, specifying the `fieldPath`, `description`, and `validationCode` of the issue. Use the Google Analytics Event Builder for interactive event construction.\n"],null,["Choose your platform: \nFirebase gtag.js\n\nThe Google Analytics Measurement Protocol does not return\n`HTTP` error codes, even if an event is malformed or missing required\nparameters. To ensure your events are valid, you should test them against the\nMeasurement Protocol validation server before deploying them to production.\nAfter you have validated that your events are structured properly, you should\n[verify your implementation](/analytics/devguides/collection/protocol/ga4/verify-implementation) to make sure you're using the correct keys.\n| **Caution:** The validation server does *not* validate the `api_secret` or Carefully review those values to make sure they are correct.\n\nYou can either call the validation server directly, or use the [Google Analytics\nEvent Builder](https://ga-dev-tools.web.app/ga4/event-builder/). The Google Analytics Event Builder lets you interactively\nconstruct events, and uses the Measurement Protocol validation server to\nvalidate them.\n\nThis guide describes how to send events to the Measurement Protocol for Google\nAnalytics 4 validation server and interpret the response.\n| **Important:** Events sent to the validation server don't show up in reports.\n\nSend events for validation\n\nThe only difference in the request for events sent to the Measurement Protocol\nand the Measurement Protocol validation server is the URL.\n\n| Server | URL |\n|----------------------------------------|-------------------------|\n| Measurement Protocol | `/mp/collect` |\n| Measurement Protocol validation server | `/`*debug*`/mp/collect` |\n\nAll other request fields are the same. See the [protocol](/analytics/devguides/collection/protocol/ga4/reference) reference for full\ndetails on constructing a valid request.\n\nThe following code shows an invalid event being sent to the Measurement Protocol\nvalidation server:\n| **Tip:** If you want your data to be collected in the EU, change the URL passed to the `fetch` method to begin with `https://region1.google-analytics.com` instead of `https://www.google-analytics.com`.\n\nValidation response\n\nHere's the validation server's response to the previous event: \n\n {\n \"validationMessages\": [\n {\n \"fieldPath\": \"events\",\n \"description\": \"Event at index: [0] has invalid name [_badEventName]. Names must start with an alphabetic character.\",\n \"validationCode\": \"NAME_INVALID\"\n }\n ]\n }\n\nHere's the validation server's response to a request with no validation issues: \n\n {\n \"validationMessages\": []\n }\n\nResponse\n\n| Key | Type | Description |\n|----------------------|---------------------------------------------------|----------------------------------|\n| `validationMessages` | Array\\\u003c[ValidationMessage](#validation_message)\\\u003e | An array of validation messages. |\n\nValidationMessage\n\n| Key | Type | Description |\n|------------------|------------------------------------|--------------------------------------------------|\n| `fieldPath` | string | The path to the field that was invalid. |\n| `description` | string | A description of the error. |\n| `validationCode` | [ValidationCode](#validation_code) | A validation code that corresponds to the error. |\n\nValidationCode\n\n| Value | Description |\n|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|\n| `VALUE_INVALID` | The value provided for a `fieldPath` was invalid. See [limitations](/analytics/devguides/collection/protocol/ga4/sending-events#limitations). |\n| `VALUE_REQUIRED` | A required value for a `fieldPath` was not provided. |\n| `NAME_INVALID` | The name provided was invalid. See [limitations](/analytics/devguides/collection/protocol/ga4/sending-events#limitations). |\n| `NAME_RESERVED` | The name provided was one of the reserved names. See [reserved names](/analytics/devguides/collection/protocol/ga4/reference#reserved_names). |\n| `VALUE_OUT_OF_BOUNDS` | The value provided was too large. See [limitations](/analytics/devguides/collection/protocol/ga4/sending-events#limitations). |\n| `EXCEEDED_MAX_ENTITIES` | There were too many parameters in the request. See [limitations](/analytics/devguides/collection/protocol/ga4/sending-events#limitations). |\n| `NAME_DUPLICATED` | The same name was provided more than once in the request. |"]]