Skip to main content

ShopifyQL API

The ShopifyQL API checks whether analytics is available to the current user. Use it to decide what your app shows before you render analytics web components.

Metric cards wait for initialization on their own, so you don't need to call this API to render a card. If analytics isn't available and your app doesn't check, then each card shows a generic error.

  • Custom unavailable state: Show your own message, empty state, or fallback content instead of the metric card's generic error.
  • Loading state: Show a loading indicator while analytics initializes.
  • Conditional sections: Hide an analytics section from users who can't view analytics.

The shopifyQL API is available on the shopify global. All methods are asynchronous and return a Promise.

Anchor to available
available
() => Promise<boolean>
required

Checks whether analytics is available to the current user. Resolves to true when analytics is available, and false when it isn't, for example, when the user doesn't have permission to view analytics. A false result doesn't include the reason.

Examples

js

const isAvailable = await shopify.shopifyQL.available();
// => true

Was this page helpful?