Merchant Center 自定义报告中提供的细分功能可以通过在查询中添加相应字段在 Reporting API 中实现。例如,查询 segments.program 会生成一份报告,其中包含每个计划(购物广告、非付费商品详情等)的一行,该行包含 SELECT 子句中指定的相应计划的指标(展示次数、点击次数等)。
与 Merchant Center 中的自定义报告一样,您可以使用 Reporting API 在同一查询中指定多个细分。
以下示例查询会检索您账号中所有产品在 30 天内的点击次数,并按 program 和 offer_id 进行细分:
[null,null,["最后更新时间 (UTC):2025-08-13。"],[[["\u003cp\u003eThe Merchant API is the new version of the Content API for Shopping and offers improved integration capabilities.\u003c/p\u003e\n"],["\u003cp\u003eUse the Reporting API to segment your product data by attributes such as program, offer ID, category, and product type, allowing for granular performance analysis.\u003c/p\u003e\n"],["\u003cp\u003eCurrency and price metrics are automatically included in reports to ensure accurate interpretation of financial data.\u003c/p\u003e\n"],["\u003cp\u003eBuy on Google metrics are no longer supported and return 0 values.\u003c/p\u003e\n"],["\u003cp\u003eItem-level Buy on Google metrics can be segmented by any available segment, while order-level metrics have restrictions with certain product dimensions.\u003c/p\u003e\n"]]],["The Merchant API's beta version is introduced, replacing the Content API for Shopping. The Reporting API allows segmentation of custom reports by adding fields to a query, such as `segments.program`. A sample query retrieves clicks segmented by `program` and `offer_id`. Product attributes can be categorized using Google's taxonomy (`segments.category_l1`, etc.) or custom types (`segments.product_type_l1`, etc.). Price metrics utilize `segments.currency_code`. Buy on Google metrics are deprecated. The documentation provides a full list of segments.\n"],null,["# Segmentation, available in Merchant Center\n[custom reports](//support.google.com/merchants/answer/9967959), can be\nimplemented in the Reporting API by adding the appropriate field to a query. For\nexample, querying for `segments.program` results in a report with a row for each\nprogram (Shopping Ads, Free product listings, etc.) that includes the metrics\n(impressions, clicks, etc.) for that program as specified in the `SELECT`\nclause.\n\nAs with custom reports in the Merchant Center, you can specify multiple segments\nin the same query with the Reporting API.\n\nThe following sample query retrieves the clicks for all products in your account\nduring a 30-day period, segmented by `program` and `offer_id`: \n\n SELECT\n segments.program,\n segments.offer_id,\n metrics.clicks\n FROM MerchantPerformanceView\n WHERE segments.date BETWEEN '2020-11-01' AND '2020-11-30'\n\n[Run](https://developers.google.com/shopping-content/reference/rest/v2.1/reports/search?apix=true&apix_params=%7B%22merchantId%22%3A0%2C%22resource%22%3A%7B%22query%22%3A%22SELECT%20%20segments.program%2C%20%20segments.offer_id%2C%20%20metrics.clicks%20FROM%20MerchantPerformanceView%20WHERE%20segments.date%20BETWEEN%20%272020-11-01%27%20AND%20%272020-11-30%27%22%7D%7D)\n\nClick **Run** to try the sample in the **API Explorer** . After you click\n**Run** , update the merchant ID placeholder to your own merchant ID in the\nrequest URL. You can modify the query. The full query must remain on one line to\nwork with the **API explorer**.\n\nThe results from sending this query to `reports.search` is a row specifying the\nclicks for each combination of `offer_id` and `program`, like in this sample\nJSON string: \n\n {\n \"results\": [\n {\n \"segments\": {\n \"program\": \"SHOPPING_ADS\",\n \"offerId\": \"12345\"\n },\n \"metrics\": {\n \"clicks\": \"38\"\n }\n },\n {\n \"segments\": {\n \"program\": \"SHOPPING_ADS\",\n \"offerId\": \"12346\"\n },\n \"metrics\": {\n \"clicks\": \"125\"\n }\n },\n {\n \"segments\": {\n \"program\": \"FREE_PRODUCT_LISTING\",\n \"offerId\": \"12346\"\n },\n \"metrics\": {\n \"clicks\": \"23\"\n }\n },\n {\n \"segments\": {\n \"program\": \"SHOPPING_ADS\",\n \"offerId\": \"12347\"\n },\n \"metrics\": {\n \"clicks\": \"8\"\n }\n },\n {\n \"segments\": {\n \"program\": \"FREE_PRODUCT_LISTING\",\n \"offerId\": \"12347\"\n },\n \"metrics\": {\n \"clicks\": \"3\"\n }\n }\n ]\n }\n\n| **Caution:** Keep in mind that the number of rows can increase exponentially for each additional segment field included in your report query.\n\nCategory and product type\n-------------------------\n\nThe Merchant Center Query Language supports segmenting metrics by two groups of\nattributes that you can define to organize your inventory:\n\nCategory levels (`segments.category_l1`, `segments.category_l2`, etc.)\n: Categories from\n [Google's product taxonomy](//support.google.com/merchants/answer/6324436).\n Google might auto-assign the category to your product if none was provided, or\n further refine the provided category.\n\nProduct type levels (`segments.product_type_l1`, `segments.product_type_l2`, etc.)\n: Product types that\n [you assign based on your categorization](//support.google.com/merchants/answer/6324406).\n Unlike the category levels, there is no predefined set of supported values.\n\nBoth the category and product type attributes are organized in a hierarchy with\nmultiple levels. The\n[product specification](//support.google.com/merchants/answer/7052112) separates\neach level with the `\u003e` character, but you select each level of the hierarchy\nseparately in reports.\n\nFor example, consider a product with the following product type levels: \n\n Home & Garden \u003e Kitchen & Dining \u003e Kitchen Appliances \u003e Refrigerators\n\nReports will return each level in its own field, as follows:\n\n| Segment | Value |\n|----------------------------|----------------------|\n| `segments.product_type_l1` | `Home & Garden` |\n| `segments.product_type_l2` | `Kitchen & Dining` |\n| `segments.product_type_l3` | `Kitchen Appliances` |\n| `segments.product_type_l4` | `Refrigerators` |\n\nCurrency and price metrics\n--------------------------\n\nThe `segments.currency_code` field of a `ReportRow` indicates the currency in\nwhich price metrics such as `metrics.conversion_value_micros` are returned.\nSince this is important in order to properly interpret these metrics, the\nreturned `ReportRow` will automatically include `segments.currency_code`\nwhenever you select one of the price metrics below.\n\n- `metrics.conversion_value_micros`\n\n| **Deprecated:** The following fields are no longer supported.\n\n- `metrics.aov_micros`\n- `metrics.ordered_item_sales_micros`\n- `metrics.returns_micros`\n- `metrics.shipped_item_sales_micros`\n\n| **Note:** You might still want to explicitly include `segments.currency_code` in your query for clarity and consistency between your `SELECT` clause and each `ReportRow` in the response.\n\nBuy on Google metrics\n---------------------\n\n| **Deprecated:** Buy on Google metrics are no longer supported and retrieving them returns 0 starting from May 2024 (including historical values for past dates).\n\nThe Merchant Center Query Language supports two categories of metrics for Buy on\nGoogle orders: item-level metrics and order-level metrics.\n\nitem-level metrics\n\n: Metrics calculated based on the items within orders, and associated with the\n product dimensions of the items in each order.\n\n - `metrics.item_days_to_ship`\n - `metrics.item_fill_rate`\n - `metrics.ordered_items`\n - `metrics.ordered_item_sales_micros`\n - `metrics.rejected_items`\n - `metrics.returned_items`\n - `metrics.return_rate`\n - `metrics.returns_micros`\n - `metrics.shipped_items`\n - `metrics.shipped_item_sales_micros`\n - `metrics.unshipped_items`\n\norder-level metrics\n\n: Metrics calculated on a per-order basis.\n\n - `metrics.aos`\n - `metrics.aov_micros`\n - `metrics.days_to_ship`\n - `metrics.orders`\n - `metrics.shipped_orders`\n - `metrics.unshipped_orders`\n\n: Order-level metrics are *not* associated with the product dimensions of the\n items in each order.\n\nYou can select item-level metrics in combination with any available segment.\nHowever, selecting order-level metrics in combination with any of the following\nproduct dimension segments will fail:\n\n- `segments.brand`\n- `segments.category_l1`, `segments.category_l2`, `segments.category_l3`, `segments.category_l4`, `segments.category_l5`\n- `segments.custom_label1`, `segments.custom_label2`, `segments.custom_label3`, `segments.custom_label4`, `segments.custom_label5`\n- `segments.offer_id`\n- `segments.product_type_l1`, `segments.product_type_l2`, `segments.product_type_l3`, `segments.product_type_l4`, `segments.product_type_l5`\n- `segments.title`\n\nFind out more\n-------------\n\nFor a complete list of segments, check out the\n[documentation](/shopping-content/reference/rest/v2.1/reports/search#segments)."]]