Skip to content

Technical information

SparkLayer is designed to be as lightweight as possible and uses modern JavaScript technology to power the frontend.

How SparkLayer is loaded

SparkLayer is fully hosted, so there's no code for you to host or maintain.

For performance, the SparkLayer Frontend only loads when a customer logs in to your website. The interfaces load asynchronously, so even though SparkLayer is a hosted third-party solution, the impact on page load times is negligible.

Browser support

SparkLayer supports the latest two versions of these browsers:

  • Google Chrome
  • Mozilla Firefox
  • Apple Safari
  • Microsoft Edge
  • Apple Safari for iOS
  • Google Chrome for Android and iOS

SparkLayer may not work fully with beta or pre-release versions of these browsers.

Mobile support

The frontend interfaces work on desktop, tablet and mobile, so customers can browse your website on any device.

Building custom interfaces

To build more custom layouts on top of the SparkLayer Frontend, see the JavaScript SDK.

Event tracking for analytics (Google Analytics, GA4)

SparkLayer can send B2B events, such as add to cart, begin checkout and purchase, to Google Analytics (GA4), Google Tag Manager (GTM) or your own analytics code. You set it up with the analytics option in sparkOptions, so you'll need a developer to add it to your Core Script.

Enabling Google Analytics or GTM

Add an analytics object with a list of providers. Each provider has a handler (which analytics tool to send to) and the events to send. This example sends every event to GA4, GTM and a custom function:

sparkOptions
window.sparkOptions = {
  ...window.sparkOptions,
  analytics: {
    providers: [
      {
        handler: 'ga', // Google Analytics (GA4)
        events: {
          addToCart: true,
          cartUpdate: true,
          shoppingListSave: true,
          shoppingListLoad: true,
          shoppingListDelete: true,
          csvUpload: true,
          quickAdd: true,
          finalStageCheckout: true,
          shippingUpdate: true,
          beginCheckout: true,
          purchase: true,
          viewCart: true,
        },
      },
      {
        handler: 'gtm', // Google Tag Manager
        events: {
          addToCart: true,
          cartUpdate: true,
          shoppingListSave: true,
          shoppingListLoad: true,
          shoppingListDelete: true,
          csvUpload: true,
          quickAdd: true,
          finalStageCheckout: true,
          shippingUpdate: true,
          beginCheckout: true,
          purchase: true,
          viewCart: true,
        },
      },
      {
        handler: function (eventName, eventParam) {
          // Your own analytics code
        },
        events: {
          addToCart: true,
          purchase: true,
        },
      },
    ],
  },
};

The ...window.sparkOptions line keeps the options you've already set; without it, this object replaces them.

Provider options

Provider typeDescription
'ga'Integrates with Google Analytics (GA4). This works best with Shopify's GA4 integration (opens in a new tab).
'gtm'Integrates with Google Tag Manager.
functionA custom analytics handler, for other analytics platforms or your own tracking logic. See Custom analytics provider.

Available events

Event nameDescription
addToCartTriggered when a product is added to the cart.
cartUpdateFired when the cart is updated (for example, quantity changes or items removed).
shoppingListSaveOccurs when a shopping list is saved.
shoppingListLoadOccurs when a shopping list is loaded.
shoppingListDeleteOccurs when a shopping list is deleted.
csvUploadTriggered when a CSV file is uploaded.
quickAddFired during quick add actions.
finalStageCheckoutOccurs at the final stage of the checkout process.
shippingUpdateFired when shipping details are updated during checkout.
beginCheckoutTriggered when the checkout process begins.
purchaseOccurs when a purchase is completed.
viewCartFired when the cart is viewed.

Custom analytics provider

To send events to an analytics service SparkLayer doesn't support natively, set handler to a function. It receives the event name and its parameters, so you can add any tracking logic:

Custom analytics provider
{
  handler: function (eventName, eventParam) {
    // Example: send the event to your own analytics endpoint
    fetch('https://your-analytics-endpoint.com/track', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        event: eventName,
        parameters: eventParam,
      }),
    });
  },
  events: {
    addToCart: true,
    cartUpdate: true,
    // ... other events ...
  },
}

Next steps

Was this page helpful?

Last updated