Frontend Integration Guide
The process of installing the SparkLayer Frontend is designed to be as streamlined as possible, requiring only a small number of code changes to your website. Once the code has been added, your B2B customers can then log in to your website and start placing B2B orders.
The process of installing the SparkLayer frontend involves three main steps:
Adding the SparkLayer Core Script This is a JavaScript code snippet that instructs your website to display all the frontend interfaces required for SparkLayer to work.
Adding the product page scripts To display customer-specific pricing and the ability to add products to an order, special SparkLayer widgets are installed on your website's product pages.
Setting the design customisations SparkLayer has CSS configurations that allow control over the look and feel such as colours, typefaces, and spacing.
Beyond these steps, you can then apply further customisations and configurations to really tailor your B2B experience. You can learn more in Configurations๏ปฟ as well as platform-specific recommendations in our Integrations๏ปฟ guide.
Ready to get started? Within the SparkLayer Dashboard, the Frontend Integration section gives you personalised instructions on how to implement the special code snippets on your website.
The SparkLayer Core Script works by adding a special JavaScript code snippet into your website's theme. Once added, this then enables SparkLayer to render the special Frontend Interfaces๏ปฟ that allow your B2B customers to place orders, manage their account, and more.
To install the SparkLayer Core Script, it simply needs to be included within the main "header" of your website's source code within the <head>...</head> tags. For Shopify, you'll need to add this to the file /layout/theme.liquid
![Document image Document image](https://images.archbee.com/kxppJrvFK15E9wXbMKaTP/vMYsiehB3_WTJkt7gZtqu_image.png?format=webp)
To get started, head over to the SparkLayer Dashboard and you'll see your customised SparkLayer Core Script within the Frontend Configurations.
You'll also notice a special number at the bottom of the code shown to you, for example:
The number at the end denotes the version of SparkLayer, e.g. 1.6.x. Each time a new update is released (e.g. a new feature), this number can be updated to benefited from the latest changes. To see what's new, please see make sure to bookmark What's New!๏ปฟ.
From a technical point of view, the Core Script provides SparkLayer with key information that controls how it works on your website.
This information includes:
Item | Details |
siteId | The website's unique identifier (learn more๏ปฟ) |
platform | The eCommerce platform of the website |
language | The language to be used |
accountRedirect | The URL to redirect logged in customers to |
display | Which display configurations to enable (learn more๏ปฟ) |
auth | The authentication details of the logged in customer |
version | The <script async sets the version (see above) |
The SparkLayer Core Script also includes the ability to add special customisations and configurations to quickly enable (or disable) specific features.
Modifying the core script follows standard JavaScript conventions and you'll need to make sure each line has the appropriate markup (e.g. a comma at the end of each line).
Available configurations You can learn more about all the available configurations on SparkLayer in our guide here๏ปฟ.
The product page scripts are the special interfaces B2B customers see when they login to your website.
There are three interfaces available:
๏ปฟProduct Detail Interface๏ปฟ This is show on your product detail pages and allow customers to rapidly add products to an order in a special 'table view'. Learn more๏ปฟ๏ปฟ
![Document image Document image](https://images.archbee.com/kxppJrvFK15E9wXbMKaTP/dajgJUodEp9gw5t_Ns1jA_image.png?format=webp)
๏ปฟProduct Card Interface๏ปฟ This is shown anywhere a "product card" is shown such as on a product collection page or product upsell area. Learn more๏ปฟ๏ปฟ
![Document image Document image](https://images.archbee.com/kxppJrvFK15E9wXbMKaTP/X5pInSAAkIWqkEcm0xbQZ_image.png?format=webp)
๏ปฟProduct Price Interface๏ปฟ This allows you to display a product's B2B price anywhere on your website, whether a product detail page or product collection page. Learn more๏ปฟ
![Document image Document image](https://images.archbee.com/kxppJrvFK15E9wXbMKaTP/EoOgtj-ocPsgYSaM3Oa37_image.png?format=webp)
In terms of implementing the product page scripts, there are two key steps to follow:
Hiding elements If you're installing SparkLayer on your existing retail website, you will want to ensure specific elements are hidden to ensure your B2B customers see the correct pricing and content. For example, this may include your existing retail pricing, add to cart button, variant options and the quantity selector. To do this, SparkLayer has a special tag you can add to any HTML element (see below)
Displaying the SparkLayer interfaces Special code snippets need to be added to your product pages, e.g. product detail page and product collection page. When a B2B customer logs in, these will automatically show to them and they can see prices, add items to an order, view their account, and checkout. You can learn more about the specific interfaces and how to customise them within the Frontend Interfaces๏ปฟ guide.
SparkLayer lets you hide any element on your website by using a special HTML tag. This can be added to any HTML element that you want to be hidden from your B2B customers.
Typically elements that you would typically hide include:
- Price information
- Product variant information
- Quantity selection
- Buy button
![Document image Document image](https://images.archbee.com/kxppJrvFK15E9wXbMKaTP/GoODnZ-GsFhmWROK9Ni7l_image.png?format=webp)
To get started, you'll require access to the source code of your website and you'll need to locate the specific files that contain the elements you want to hide. For example, this could include editing the following pages
- A product detail page
- A product collection page
- Specific "components" that are used in multiple locations on your website
Once you've located the files, you can then use the special data-spark="b2c-only" to hide elements. This essentially adds a display: none within the CSS of your website and then hides the element when a logged in B2B customer views the page.
Please note This step requires changing the code of your website and you may want to consult an expert on how best to apply this to your website. For platform-specific guidance, please refer to Integrations๏ปฟ๏ปฟ
Once you've completed the step above, you can then proceed to add the special SparkLayer Frontend Interfaces๏ปฟ.
Interface | Details |
Product Detail | This is shown on your product detail pages and allow customers to rapidly add products to an order. Learn more๏ปฟ about how to add the code snippets |
Product Card | This is shown anywhere a "product card" is shown such as on a product collection page. Learn more๏ปฟ about how to add the code snippets |
Product Price | This allows you to display a product's B2B price anywhere on your website. You can use this instead of or alongside the "Product Card" Learn more๏ปฟ about how to add the code snippets |
SparkLayer by default has a relatively neutral user interface but it's possible to update nearly all aspects of the look and feel using special CSS variables.
- Colours
- Typography (e.g. typefaces and font sizing)
- Spacing (e.g. padding and margin)
- Button styling
- Form styling
As with the SparkLayer Core Script, the CSS code can be added to your existing CSS stylesheets or placed within the main header of your website's source code. If you're placing the CSS in your main header, remember to wrap it within the <head>...</head> tags.
![Document image Document image](https://images.archbee.com/kxppJrvFK15E9wXbMKaTP/7vDQr0cPNevSuKwwP--9l_image.png?format=webp)
An effective way to determine the colours you want to change is to use your browser 'Inspect Element' tool. All styling for SparkLayer uses special styling codes that are proceeded with --spark- and each one can be isolated and updated.
In the Inspect Element tool, you'll see something like the below. Nearly all styling elements (e.g. for a button) can be replaced and these simply needed to be added to your websites source code. Learn more in Customising the Design๏ปฟ๏ปฟ
Customisations available For all design customisations available please see our Customising the Design๏ปฟ guide.
If you're in the process of setting up SparkLayer on your website, we've included a handy checklist below to make sure you've captured everything:
Core script
- You've added theย SparkLayer Core Scriptย to your website header
Product detail page
- You've added the SparkLayer Product Detail Page widget to your product detail pages.
- You've hidden any content that you don't want to show to B2B customers, such as your regular "DTC" pricing, add to cart buttons, "sticky" content that references pricing, or non-B2B content
Product cards
- You've added the SparkLayer Product Card widget to your product cards (typically shown on your collection and category pages).
- You've hidden any content that you don't want to show to B2B customers, such as your regular "DTC" pricing, add to cart buttons, "quick buy" buttons, or non-B2B content
- You've checked all areas of your website that include product cards such as the homepage and product recommendations
CSS and design
- You've added the SparkLayer CSS to your website (e.g. in the header or in a CSS file) and you've applied any styling formatting to match your branding
Cart (and Cart Drawer)
- You've checked that when clicking the "cart icon" in your website header, this triggers the My Cart Interface. If it doesn't, you need to ensure the cart is set to not trigger JavaScript for B2B customers and points to the URL /cart
General site audit
- You've checked functionality such as site search and wish-lists to ensure regular (DTC) prices are hidden (you can hide this in CSS or in the code)
๏ปฟ