Segmentation

You can use segments fields for segmentation in performance reports. For example, querying for marketingMethod returns a report with a row for each marketing method, and the metrics that you specify for that marketing method in the SELECT clause.

As with custom reports in the Merchant Center, you can specify multiple segments in the same query with the Merchant Reports API.

Here's a sample query that returns the clicks for all products in your account during a 30-day period, segmented by marketingMethod and offerId:

SELECT marketingMethod, offerId, clicks
FROM ProductPerformanceView
WHERE date BETWEEN '2020-11-01' AND '2020-11-30'

The response from this query includes a row for each combination of offerId and marketingMethod, with the number of clicks for that combination:

{
  "results": [
    {
      "productPerformanceView": {
        "marketingMethod": "ADS",
        "offerId": "12345",
        "clicks": "38"
      }
    },
    {
      "productPerformanceView": {
        "marketingMethod": "ADS",
        "offerId": "12346",
        "clicks": "125"
      }
    },
    {
      "productPerformanceView": {
        "marketingMethod": "ORGANIC",
        "offerId": "12346",
        "clicks": "23"
      }
    },
    {
      "productPerformanceView": {
        "marketingMethod": "ADS",
        "offerId": "12347",
        "clicks": "8"
      }
    },
    {
      "productPerformanceView": {
        "marketingMethod": "ORGANIC",
        "offerId": "12347",
        "clicks": "3"
      }
    }
  ]
}

Category and product type

The Merchant Center Query Language supports segmenting metrics by two groups of attributes that you can define to organize your inventory:

Category levels
Categories from Google's product taxonomy. Google might auto-assign the category to your product if none was provided, or further refine the provided category.
Product type levels
Product types that you assign based on your categorization. Unlike the category levels, there is no predefined set of supported values.

Both the category and product type attributes are organized in a hierarchy with multiple levels. The product specification separates each level with the > character, but you select each level of the hierarchy separately in reports.

For example, consider a product with the following product type levels:

Home & Garden > Kitchen & Dining > Kitchen Appliances > Refrigerators

Reports return each level in its own field:

Segment Value
product_type_l1 Home & Garden
product_type_l2 Kitchen & Dining
product_type_l3 Kitchen Appliances
product_type_l4 Refrigerators

Currency and price metrics

Price metrics, such as conversionValue, are represented using the Price type. If the metric is available in multiple currencies, the value for each currency is returned in a separate row. For example, the following query:

SELECT conversionValue
FROM ProductPerformanceView
WHERE date = '2020-11-01'

returns the following results:

{
  "results": [
    {
      "productPerformanceView": {
        "conversionValue": {
          "amountMicros": "150000000",
          "currencyCode": "USD"
        }
      }
    },
    {
      "productPerformanceView": {
        "conversionValue": {
          "amountMicros": "70000000",
          "currencyCode": "CAD"
        }
      }
    }
  ]
}

If you request both price and non-price metrics in a query, price metrics are returned in separate result rows from non-price metrics, one result row per currency code. For example, the following query:

SELECT conversions, conversionValue
FROM ProductPerformanceView
WHERE date = '2020-11-01'

returns the following response:

{
  "results": [
    {
      "productPerformanceView": {
        "conversions": "27",
        "conversionValue": {
          "amountMicros": "0",
          "currencyCode": ""
        }
      }
    },
    {
      "productPerformanceView": {
        "conversions": "0",
        "conversionValue": {
          "amountMicros": "150000000",
          "currencyCode": "USD"
        }
      }
    },
    {
      "productPerformanceView": {
        "conversions": "0",
        "conversionValue": {
          "amountMicros": "70000000",
          "currencyCode": "CAD"
        }
      }
    }
  ]
}

All fields you select are returned in the response, even if their value is still the default value or zero.