BigCommerce
Store Operations
Settings
Data Layer

Data Layer Settings in the GraphQL Admin API

The GraphQL Admin API's data layer setting allows BigCommerce to send data from BigCommerce-hosted storefronts to third-party analytics providers through Big Open Data Layer. Bigcommerce can build native integrations to analytics providers, such as Google Analytics 4, using the data layer. Partners may also build their own integrations using the data layer. In each case, you must first enable the data layer using the GraphQL Admin API. The data layer is enabled at the global level.

This guide shows you how to use the GraphQL Admin API's data layer queries and mutations. For full schema, see the GraphQL Admin API reference.

Prerequisites

You need a store-level API account that contains the following OAuth scopes:

UI NamePermissionParameterDescription
Information & Settingsmodifystore_v2_informationView and modify store information and settings

For more about API accounts that generate access_tokens, see API Accounts and OAuth Scopes.

Get data layer

Send the following query to retrieve whether the data layer is enabled in the store:

Example query: Get data layer enabled flag
POST https://api.bigcommerce.com/stores/{{STORE_HASH}}/graphql
X-Auth-Token: {{ACCESS_TOKEN}}
Content-Type: application/json
Accept: application/json
 
query {
  store {
    settings {
      dataSolutions {
        isDataLayerEnabled
      }
    }
  }
}

Enable data layer

Send the following mutation to enable the data layer in the store:

Example mutation: Enable data layer
POST https://api.bigcommerce.com/stores/{{STORE_HASH}}/graphql
X-Auth-Token: {{ACCESS_TOKEN}}
Content-Type: application/json
Accept: application/json
 
mutation {
  settings {
    dataSolutions {
      updateDataLayer (input: {isDataLayerEnabled: true}) {
        dataSolutions {
          isDataLayerEnabled
        }
      }
    }
  }
}

Disable data layer

Send the following mutation to disable the data layer in the store:

Example mutation: Disable data layer
POST https://api.bigcommerce.com/stores/{{STORE_HASH}}/graphql
X-Auth-Token: {{ACCESS_TOKEN}}
Content-Type: application/json
Accept: application/json
 
mutation {
  settings {
    dataSolutions {
      updateDataLayer (input: {isDataLayerEnabled: false}) {
        dataSolutions {
          isDataLayerEnabled
        }
      }
    }
  }
}

Resources

Did you find what you were looking for?