با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
پلتفرم خود را انتخاب کنید:
پروتکل اندازهگیری Google Analytics کدهای خطای HTTP را باز نمیگرداند، حتی اگر رویدادی بدشکل باشد یا پارامترهای لازم را نداشته باشد. برای اطمینان از معتبر بودن رویدادها، باید آنها را در برابر سرور اعتبارسنجی پروتکل اندازه گیری قبل از استقرار در تولید آزمایش کنید. بعد از اینکه تأیید کردید که رویدادهای شما به درستی ساختار یافته اند، باید اجرای خود را تأیید کنید تا مطمئن شوید که از کلیدهای صحیح استفاده می کنید.
میتوانید مستقیماً با سرور اعتبارسنجی تماس بگیرید یا از Google Analytics Event Builder استفاده کنید. Google Analytics Event Builder به شما امکان می دهد رویدادها را به صورت تعاملی بسازید و از سرور اعتبارسنجی پروتکل اندازه گیری برای تأیید اعتبار آنها استفاده کنید.
این راهنما نحوه ارسال رویدادها به پروتکل اندازه گیری سرور اعتبارسنجی Google Analytics 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"}]}
در اینجا پاسخ سرور اعتبارسنجی به درخواستی بدون مشکل اعتبار سنجی آمده است:
تاریخ آخرین بهروزرسانی 2025-08-26 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-26 بهوقت ساعت هماهنگ جهانی."],[[["\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. |"]]