Google Analytics Data API v1 可为 Google Analytics 媒体资源生成报告。API 请求必须指定一个数字 Google Analytics 媒体资源标识符。Data API 的文档和示例代码将此 ID 称为 GA_PROPERTY_ID。
用法
所有 Data API 方法都要求在网址请求路径中以 properties/GA_PROPERTY_ID 的形式指定 Google Analytics 媒体资源标识符,例如:
POST https://analyticsdata.googleapis.com/v1beta/properties/GA_PROPERTY_ID:runReport
如果您使用的是 Data API 客户端库之一,则无需手动操作请求网址路径。大多数 API 客户端都会提供一个 property 参数,该参数需要 properties/GA_PROPERTY_ID 形式的字符串。如需查看有关如何使用客户端库的示例,请参阅快速入门指南。
我的房源 ID 是什么?
如果您在以下任一产品中配置了分析报告,则可以使用 Data API:
Google Analytics
Google Analytics 有多种媒体资源类型。如需使用 Data API,媒体资源必须是 Google Analytics 媒体资源,而不是 Universal Analytics 媒体资源。Universal Analytics 是 Google Analytics 的旧版,不受 Data API 支持。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eThe Google Analytics Data API v1 allows you to access Google Analytics property data using a numeric property identifier (\u003ccode\u003eGA_PROPERTY_ID\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eYou can find your \u003ccode\u003eGA_PROPERTY_ID\u003c/code\u003e in the Property Settings of your Google Analytics, Firebase, or AdMob account.\u003c/p\u003e\n"],["\u003cp\u003eUniversal Analytics properties are not supported by the Data API; use the Google Analytics Reporting API v4 instead.\u003c/p\u003e\n"],["\u003cp\u003eClient libraries simplify API usage by providing a \u003ccode\u003eproperty\u003c/code\u003e parameter, eliminating the need to manually manipulate request URLs.\u003c/p\u003e\n"]]],["The Google Analytics Data API v1 requires a numeric property identifier (`GA_PROPERTY_ID`) to generate reports. This ID is specified in the API request URL as `properties/GA_PROPERTY_ID`. You can find your property ID in Google Analytics' Property Settings, Firebase's Google Analytics Integration page, or by navigating from AdMob to Firebase. The Data API only supports Google Analytics properties, not Universal Analytics properties which uses the Google Analytics Reporting API v4.\n"],null,["# Property ID\n\nThe Google Analytics Data API v1 produces reports for [Google Analytics\nproperties](//support.google.com/analytics/answer/9304153#property).\nAPI requests are required to specify a numeric Google Analytics\nproperty identifier. The documentation and sample code of the Data API refer to\nthis ID as `GA_PROPERTY_ID`.\n\nUsage\n-----\n\nAll Data API methods require the Google Analytics property identifier to be\nspecified inside a URL request path in the form of `properties/GA_PROPERTY_ID`,\nsuch as: \n\n POST https://analyticsdata.googleapis.com/v1beta/properties/GA_PROPERTY_ID:runReport\n\nIf you are using one of the [Data API client libraries](/analytics/devguides/reporting/data/v1/client-libraries), there\nis no need to manipulate the request URL path manually. Most API clients\nprovide a `property` parameter that expects a string in the form of\n`properties/GA_PROPERTY_ID`. See [Quick start guide](/analytics/devguides/reporting/data/v1/quickstart-client-libraries)\nfor examples of using the client libraries.\n\nWhat is my property ID?\n-----------------------\n\nYou can use the Data API if you have configured analytics reports in either of\nthe following products:\n\n### Google Analytics\n\nGoogle Analytics has multiple types of Properties. To use the Data API, a\nproperty must be a Google Analytics property, as opposed to Universal\nAnalytics. Universal Analytics is an older version of Google Analytics and is\nnot supported by the Data API.\n\nTo determine a Google Analytics property ID:\n\n1. Visit Google Analytics at \u003chttps://analytics.google.com/\u003e.\n2. Select Admin.\n3. Select the Property.\n4. Select Property Settings.\n\nIf the Property Settings shows a numeric \"PROPERTY ID\" such as \"123...\", this\nis the numeric ID of your Google Analytics property.\n| **Note:** If the Property Settings shows a \"Tracking ID\" such as \"UA-123...-1\", this Property is a Universal Analytics property, and the Analytics data for that property cannot be reported on in the Data API. For that property, you can use the [Google Analytics Reporting API v4](/analytics/devguides/reporting/core/v4) to produce analytics data reports.\n\n### Firebase\n\nIf you have linked Google Analytics to Firebase, you will see analytics data for\nyour project in Firebase. To learn more about linking, see [Link Google\nAnalytics to Firebase](//support.google.com/analytics/answer/9289234).\n\nTo determine the Google Analytics property for a Firebase project:\n\n1. Visit the Firebase console at \u003chttps://console.firebase.google.com/\u003e.\n2. Select your project.\n3. Select Project settings.\n4. Select Integrations.\n5. Select your Google Analytics Integration.\n\nThe Google Analytics Integration page will show a numeric \"Property ID\" such as\n\"123...\". This is the numeric ID of your Google Analytics property.\n\n### AdMob\n\nIf you have [enabled user metrics](//support.google.com/admob/answer/9263723)\nand\n[linked your apps to Firebase](//support.google.com/admob/answer/6383165)\nin AdMob, you will see user metrics in AdMob for your app.\n| **Note:** Currently, linking your AdMob app to Firebase and adding the Google Analytics for Firebase SDK to your app are optional. However, with the [upcoming changes to the collection of user metrics](//support.google.com/admob/answer/13973847) in late 2023, linking to Firebase and adding the Analytics SDK will be required to collect [user metrics for AdMob](//support.google.com/admob/answer/9281746) as well as to [explore and work with this data](//firebase.google.com/docs/admob/analytics-and-firebase).\n\nTo determine the Google Analytics property for an AdMob app:\n\n1. Visit AdMob at \u003chttps://apps.admob.com/\u003e.\n2. Select your app.\n3. Select App Overview.\n4. Select \"FIREBASE DASHBOARD\".\n5. Follow the above Firebase instructions starting with \"Select Project settings.\""]]