The GraphQL Storefront API’s scripts query allows you to fetch storefront scripts configured in your BigCommerce control panel. This feature is designed to help merchants and developers programmatically retrieve both inline and external scripts that are executed on the storefront, providing visibility and control over scripts used for analytics, integrations, and custom storefront functionality.
A storefront script is a snippet of JavaScript or an external script URL that can be injected into your storefront pages. Storefront scripts are managed per storefront through the BigCommerce control panel and can be used for a wide variety of purposes, such as analytics tracking, integrations with third-party services, or adding custom functionality to storefront pages.
Before using the scripts query, ensure you have the following:
To learn more about authenticating GraphQL Storefront API requests, see the Authentication and Example Requests.
The scripts query provides a simple way to retrieve all scripts set up for your storefront. You can use this query to audit which scripts are currently active, fetch metadata such as consent category and visibility, and distinguish between inline and external scripts. The API supports filtering, pagination, and provides detailed information about each script, including its location on the page (e.g., <head>, <footer>), integrity hashes, and type.
Begin with the following steps:
https://store-{store_hash}.mybigcommerce.com/graphql).Authorization header with your Storefront API token.scripts query.The following example query will fetch the full set of storefront scripts.