Smart Size Chart
A script to support e-commerce websites in providing garment size recommendations.
Quick Start Guide
For Shopify Users
To integrate the Smart Size Chart on your Shopify site, follow these quick steps:
Integrate 'Add To Cart' Functionality To Maximize Conversion, either using the
bmi_add_to_cart
event or by using thebmi_selected_item
event
For Non-Shopify Users
To integrate the Smart Size Chart on your site, follow these quick steps
Integrate 'Add To Cart' Functionality To Maximize Conversion, either using the
bmi_add_to_cart
event or by using thebmi_selected_item
event
Required Product Data
Shopify Sites
Bold Metrics requires you to install a Private Shopify App, which grants Bold Metrics API access to your product data. We check your product catalog daily to check for product updates so your customers will get recommendations for the latest products.
Follow these steps to install a Private Shopify App:
From your Shopify admin, go to Apps in the left navigation bar.
Click App and sales channel settings in the command palette.
Click Develop apps.
Click Create an app.
Enter a name for your app that describes this application related to Bold Metrics.
Click Create app.
Click Admin API Configuration and select Edit.
In the search toolbar, search products, and select read_products.
In the search toolbar, now search orders, and select read_orders.
Click Save.
Select the API Credentials tab, and under Access tokens, click Install App (select Install if a popup is shown).
Select reveal token once, and copy the token. In the API key and secret key section, copy the API Key and API Secret key and send all three to Bold Metrics.
Non-Shopify Sites
Bold Metrics requires product data for products Bold Metrics will support. Depending on the product types and available data, your team may be asked to fill out a product template, provide a feed via FTP, or expose data in the browser.
Depending on the next steps, your account representative will communicate timeline and subsequent steps to complete onboarding.
Integrating the Smart Size Chart
Adding Configuration and a Script Tag
Include this script tag in your Product Template (PDP) if you are a Shopify client, or in the <head> element of your PDP page if you are a non-Shopify client.
Do not add this to all pages, only the PDP. Please ensure that this script is only included once on your PDP.
Adding the boldmetrics div to your PDP
Add the following element at the location where you’d like to load the 'Find My Size' button. \
Customizing Button Styles
Various aspects of the button's UI can be customized easily, by adding data attributes to the element.
The available customizations include:
data-button-mode
= sets the button to either light purple or black. Should be set as “light” or “dark".data-text-case
= sets the text to either upper or title case. Should be set as “upper” or “title”.data-background-color
= sets background color (ex, '#4169E1')data-border-radius
= sets border radius in px (ex: '2px')data-font-family
= sets font family (ex: "cursive", "monospace", "Gill Sans Extrabold", "Helvetica")
For instance, if I wanted to turn on 'dark' mode, set the text case to 'upper', and the font-family to 'Helvetica', my boldmetrics div's code may look something like:
Adding window._boldmetrics Object to your PDP
In order for Bold Metrics to capture all product information, please add the following JavaScript to your PDP. For Shopify users, this leverages liquid templates to pull product data in JSON format.
Non-Shopify Sites
Please see the various object definitions below to see all required parameters. Please note, all items marked 'Required' or 'Conditionally Required' are necessary for Bold Metrics' Smart Size Chart to function on a PDP.
Object API Contract Definition
locale
String
Required. BCP 47 language + country code for PDP locale (en-US, en-GB, fr-FR, etc)
product
Object<Product>
Required. Top level object for product
field, see object definition below
Product Object Contract Definition
id
String
|
Number
Required. Top level ID for garment
type
String
price
String |
Number
Required. Garment sale price
sizechart
String
Required. Name for size chart for this particular garment, ideally in <gender>_<garment type>_<sizing_dimensions> format
.
If the size chart name does not contain primary and secondary sizing dimensions, primaryDimension & secondaryDimensions are required parameters.
title
String
Required. Garment Name
variants
Array<
Variant
>
Required. A list of all available variants of the garment (eg, variants for all available sizes / colors / fits), below are all fields for variant
tags
Array <
string
>
Optional. A list of tags that correspond with the product, if available
description
String
Optional. Publicly viewable description of the garment
primaryDimension
'ALPHA'|
'NUMERIC'|
'ONE_SIZE'|
'SUIT'|
'SPLIT:NUMERIC'|
'SPLIT:ALPHA'|
'COLLAR'|
'OTHER'
Conditionally Required. Required if not available in size chart field. Optional otherwise.
secondaryDimensions
Array<
'INSEAM:NUMERIC'|
'INSEAM:ALPHA'|
'INSEAM:OTHER'|
'LENGTH:SLEEVE'|
'OTHER'
>
Conditionally Required. Required if not available in size chart field. Optional otherwise.
Variant Object Contract Definition
id
String |
Number
Required. Variant ID
size
String
Required. Variant size
available
Boolean
Required. Boolean value corresponding to garment availability
description
String
Optional. If description differs from main product, please add it here
fit
String
Optional. If this garment has multiple fits on a single PDP (eg, slim, athletic, classic), include fit definition string of this particular variant.
sku
String |
Number
If SKU/ID differ, SKU is required. Otherwise optional.
sizechart
String
If variant size chart differs from parent garment size chart, this is a required field. Otherwise, optional.
additionalMetadata
Object
Optional. Object for containing additional metadata as necessary -- consult with Bold Metrics implementation team about this object
Shopify Sites
Soft Launch functionality
By default, before we officially launch, we have turned on softLaunch
in the client configuration file for your site.
When softLaunch
is active, this means that even if the Smart Size Chart JS tag is live on your site, and the Bold Metrics activator element is live, the Smart Size Chart will not be publicly visible on your site, but you will need to manually “flip a switch” using either a cookie or a specific query parameter in the URL of your PDPs to see the Smart Size Chart functioning as expected.
This allows for the following:
You, as a team, to integrate the various Bold Metrics scripts prior to completion of the integration process or prior to full SSC Button Design
Bold Metrics to test against live garment data in either a staging or production environment to ensure the experience will be working flawlessly for you and your customers
Bold Metrics and your team to work together to debug issues before we publicly “go live” and can flip the switch to activate the Smart Size Chart together!
In order to “turn on” the Smart Size Chart experience (ie, to see the SSC button as expected) while your site is in softLaunch
mode, you will need to do utilize one of the following methods:
Query Parameter:
If you’d just like to see the experience on a single product detail page, add the following query parameter to the URL you would like to see the Smart Size Chart experience on:
?bmiSoftLaunchOverride=1
.For instance, if your product detail page URL is
http://www.threadchoice.com/index.html
, you would update the url to behttp://www.threadchoice.com/index.html?bmiSoftLaunchOverride=1
Cookie Override:
If you are doing more extensive engineering work (or if the above method does not work due to URL rewrites or other issues), and would like to consistently have the experience live on a page until you turn it off, you can add the following cookie to your browser’s cookies:
bmiSoftLaunchOverride=1
Generally, you can add a cookie to a site by running
document.cookie=bmiSoftLaunchOverride=1
in the Web Developer console, or you can use some internal settings on your browser to set the cookie as active. Here’s some example instructions for Google Chrome: https://developer.chrome.com/docs/devtools/application/cookies/This will have the
softLaunch
experience active until this cookie is removed, or until the Smart Size Chart is fully activated
Integrating 'Add To Cart' Functionality
The most effective way to ensure that a customer converts is by automatically selecting a size for them once the Smart Size Chart flow has ended. We provide a DOM event to listen to when size selection is complete.
The bmi_add_to_cart
event should be used to listen to the Call To Action button in the Smart Size Chart. The best practice is to add a small script to your PDP listening for the bmi_add_to_cart
event that will select the correct size from your PDP when fired.
An example implementation is below to provide general guidance -- your script on your PDP will be different.
In this below example code block -- again, your PDP will be different:
there is an 'add to cart' button, with the id
#add-to-cart
:the inner text is the size, eg, 'Medium'
all the available sizes are buttons, with the class name
'size-option'
Since every client's PDP is different, reach out to us if you are having trouble building this functionality -- we are happy to provide guidance and assistance!
Available DOM Events
bmi_reload
If you need to ‘force’ reload the Smart Size Chart due to new data being hydrated on the page, the below event can be run and the Smart Size Chart will reload. Here’s an example of a listener for this event:
product_id_update
If you need to ‘force’ reload the Smart Size Chart due to new data being hydrated on the page, the below event can be run and the Smart Size Chart will reload. This is different from the bmi_reload
event above in that you can pass a specific product_id
with this event. Here’s an example of a listener for this event:
Available DOM Event Listeners
Data Object in DOM EventsFor certain DOM Events, we include an additional data object under the
detail
key:
fit: If a garment has fit information stored in our system, this indicator will be returned with this event.
sleeve: This is the sleeve measurement from the API call. This can also be found under the
json
object.inventory: If our system recognizes inventory for your garments, inventory data will be returned.
json: This is the API response.
size: This is the user’s selected size.
userId: This is the Bold Metrics user ID.
selectedItem: This is the selected item (only used on the
bmi_selected_item
DOM Event). Seebmi_selected_item
for more information.
bmi_close
When the ‘X’ is clicked or a user clicks outside of the modal, the bmi_close
event is fired. Here’s an example of a listener for this event:
bmi_recommendation_sent
The bmi_recommendation_sent
event is fired immediately when the API responds with a recommendation. This event has an object attached with the recommendation.
For the data included in this DOM Event, see Data Object in DOM Events
Here’s an example of a listener for this event:
bmi_selected_size
The bmi_selected_size
event is fired when any size is selected on the recommendation screen. This immediately fires when the API response is returned with the recommended best size. This will subsequently fire on each size button click by the user.
For the data included in this DOM Event, see Data Object in DOM Events
Here’s an example of a listener for this event:
bmi_add_to_cart
The bmi_add_to_cart
event is fired when the CTA (call to action) button is clicked on the recommendation screen. This button might add the size to the cart, select the size without adding it to the cart, or simply do nothing. Regardless of the button action, this event will fire when clicked.
For the data included in this DOM Event, see Data Object in DOM Events
Here’s an example of a listener for this event:
bmi_ssc_loaded
The bmi_ssc_loaded
event is fired when the Bold Metrics Smart Size Chart (SSC) app has fully loaded and collected data on the PDP. This event only fires when the SSC successfully loads - if the SSC cannot load for whatever reason (missing or invalid product metadata, page rendering / blocking issues, unable to find Bold Metrics div), this event will not fire.
For the data included in this DOM Event, see Data Object in DOM Events
Here’s an example of a listener for this event:
bmi_selected_item
The bmi_selected_item
event is fired when the SSC flow has been completed, and the SSC has performed our best effort to match up a selected size with a given variant in the window._boldmetrics
object.
This event requires the following:
The
window._boldmetrics
object to be present on the PDPAn array of variant objects to be present in the
window._boldmetrics
objectEither a
size
key in the variant itself, or some identifying information in the variant (for Shopify sites, this is usually found in either thepublic_title
/title
or thename
of the variant)
The event payload contains a data object with a selectedItem
key under the detail
object.
The selecteditem
object has the following values:
If we were able to match the user's selected size to a single matching variant:
matchedToIndividualVariant
will betrue
matchingVariants
will be an array of size 1, with the matching variant present as an object in that list
This can be used to simplify the 'add to cart' flow or perform whatever user behavior you choose. For instance, if you are using Shopify, we recommend using Shopify's Cart API functionality (which is present on your Shopify PDPs) to get the variant ID and add it directly to cart. If we were not able to match the user's selected size to an individual variant (for instance, if there are multiple colors available, multiple fits or lengths available, or if we were not able to make a reliable prediction):
matchedToIndividualVariants
will befalse
matchingVariants
may be an array of any size, with whatever variants we recognized might be a match
Here's an example of how you might use the bmi_selected_item
event:
Frequently Asked Questions
Click the arrow on the left of each box to expand the answer.
Demo
Last updated