由于 Measurement Procotol 支持来自 Google Analytics for Firebase SDK 和 gtag.js 的 ID,因此请确保您使用的是正确的 ID。您应该使用哪些 ID 取决于您使用的是 Google Analytics for Firebase SDK 还是 gtag.js。下文简要介绍了您应该使用哪些 ID:
Google Analytics for Firebase SDK
如果您使用的是 Google Analytics for Firebase SDK,则应该使用以下 ID:
firebase_app_id - 可将此 ID 添加到请求的查询参数中。此 ID 可唯一标识您的 Firebase 应用。您的应用的所有用户都具有相同的 firebase_app_id。此值可在 Firebase 控制台中的以下位置下找到: 项目设置 > 常规 > 您的应用 > 应用 ID
app_instance_id - 可将此 ID 添加到请求的 POST 正文中。此 ID 可唯一标识 Firebase 应用的指定安装。此值会因应用的每次安装而异。各个 Firebase 平台请求此值的方法如下所示:
[[["易于理解","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"]],["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eThis guide helps troubleshoot common Google Analytics 4 Measurement Protocol implementation errors, focusing on missing events and invalid user/device IDs.\u003c/p\u003e\n"],["\u003cp\u003eIf events aren't appearing, ensure your \u003ccode\u003eapi_secret\u003c/code\u003e is correct, valid, accurately copied, and you're using the appropriate device identifier (\u003ccode\u003eapp_instance_id\u003c/code\u003e or \u003ccode\u003eclient_id\u003c/code\u003e, not \u003ccode\u003eadvertising_id\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eWhen using the Measurement Protocol, select the correct IDs based on whether you're implementing via Firebase or gtag.js, as outlined in the guide.\u003c/p\u003e\n"],["\u003cp\u003eFor Firebase, utilize \u003ccode\u003efirebase_app_id\u003c/code\u003e and \u003ccode\u003eapp_instance_id\u003c/code\u003e, avoiding \u003ccode\u003efirebase_instance_id\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eFor gtag.js, use \u003ccode\u003emeasurement_id\u003c/code\u003e and \u003ccode\u003eclient_id\u003c/code\u003e for proper event tracking.\u003c/p\u003e\n"]]],["To resolve event visibility issues in Google Analytics, verify the correct `api_secret` is used, valid, and copied accurately, and avoid using `advertising_id`. For Firebase, use `firebase_app_id` in query parameters and `app_instance_id` in the POST body; retrieve `app_instance_id` using the appropriate platform's method. For gtag.js, utilize `measurement_id` in query parameters and `client_id` in the POST body. Both `client_id` and `app_instance_id` should differ for each user.\n"],null,[]]