Skip to main content

New analyticsQueryable capability for Metafield Definitions

The analyticsQueryable capability is now available on the MetafieldDefinition type in the GraphQL Admin API, enabling you to specify whether a metafield can be queried in Shopify Analytics. This enhancement allows merchants to leverage custom metafield values for filtering and grouping data, providing deeper insights into their store's performance.

You can access this capability via the MetafieldDefinition.capabilities field. It can be set during the creation or update of a metafield definition using the metafieldDefinitionCreate and metafieldDefinitionUpdate mutations.

Once enabled, the metafield becomes a dimension and filter in ShopifyQL and Shopify's Analytics, empowering merchants to refine their data analysis. Currently, this functionality supports the following MetafieldDefinition.ownerType values:

  • PRODUCT
  • PRODUCTVARIANT
  • ORDER
  • CUSTOMER

Example: Enabling Analytics Queryable on a New Metafield Definition

The following GraphQL mutation demonstrates how to enable the analyticsQueryable capability for a new metafield definition. This example sets up a metafield for products, allowing it to be used in analytics queries:

mutation {
  metafieldDefinitionCreate(definition: {
    name: "Fabric"
    namespace: "custom"
    key: "fabric"
    type: "single_line_text_field"
    ownerType: PRODUCT
    capabilities: {
      analyticsQueryable: { enabled: true }
    }
  }) {
    createdDefinition {
      id
      capabilities {
        analyticsQueryable {
          enabled
        }
      }
    }
    userErrors {
      field
      message
    }
  }
}

This mutation creates a new metafield definition with the analyticsQueryable capability enabled, making it available for use in Shopify Analytics.

Was this section helpful?