Events We Emit
StrutFit dispatches CustomEvents on window so your storefront can react to what shoppers do and to changes in their sizing data. Listen with window.addEventListener, read the payload from event.detail, and cast or narrow event to CustomEvent if you use TypeScript. In SPA code, remove your listeners when your component or app context is torn down.
All events
| Event | Emitted by | When it fires | detail |
|---|---|---|---|
strutfit:ready | Assistant Manager | StrutFit has loaded and window.StrutFit is usable | { config } |
strutfit:assistantOpened | Assistant Manager | openAssistant was called | { mode, productCode } |
strutfit:assistantClosed | Assistant Manager | The open assistant was closed | { mode } |
strutfit:chatMessageSent | Assistant Manager | The shopper sent a chat message | { source } |
strutfit:chatProductResultClicked | Assistant Manager | The shopper clicked a product result card in the chat | { productName, productPageUrl, colour } |
strutfit:footMCodeUpdated | Assistant Manager | The active footwear measurement code changed | { mCode, ...footMeasurements } |
strutfit:bodyMCodeUpdated | Assistant Manager | The active body / apparel measurement code changed | { mCode } |
strutfit:tryonMCodeUpdated | Assistant Manager | The active try-on measurement code changed | { mCode } |
strutfit:sizeProfileUpdated | Assistant Manager | The shopper's sizing profile changed without a new M-code | none |
strutfit:uniqueUserIdUpdated | Assistant Manager | The shopper signed in to or out of their StrutFit account | { id } |
strutfit:languageUpdated | Assistant Manager | The StrutFit language was set or changed | { language } |
strutfit:<component>Clicked | Each interactive component | The shopper clicked or activated the component | varies by component |
strutfit:<component>Ready | Each component | The component loaded and is visible | { id } |
strutfit:sizeUpdated | Size button | The size the button resolves for its product changed | { id, productCode, size, unit, width, sizeText } |
Assistant Manager events
These are dispatched by the Assistant Manager, so they fire on any page that loads it, whichever components you use.
Ready
strutfit:ready fires once the Assistant Manager has loaded its configuration and window.StrutFit methods such as openAssistant and isModeEnabled are ready to use.
| Event name | When it fires | detail |
|---|---|---|
strutfit:ready | StrutFit has loaded and window.StrutFit is usable | { config } |
It may fire before your listener is attached, so check window.StrutFit?.ready first. See waiting until StrutFit is ready for a full example.
function onStrutFitReady(callback) {
if (window.StrutFit?.ready) {
callback();
return;
}
window.addEventListener('strutfit:ready', callback, { once: true });
}Assistant opened and closed
These fire whenever the assistant is opened or closed, whether by a StrutFit component or by your own calls to window.StrutFit.openAssistant and window.StrutFit.closeAssistant.
| Event name | When it fires | detail |
|---|---|---|
strutfit:assistantOpened | openAssistant was called | { mode, productCode } |
strutfit:assistantClosed | The open assistant was closed, by any means | { mode } |
mode is the assistant mode being opened or closed, e.g. 'sizing' or 'chat'. productCode is an empty string when the assistant is opened without a product. strutfit:assistantClosed covers the shopper closing the assistant from inside it, clicking the backdrop or pressing Escape, as well as calls to closeAssistant.
window.addEventListener('strutfit:assistantOpened', (event) => {
const { mode, productCode } = event.detail;
// e.g. send an analytics event
});
window.addEventListener('strutfit:assistantClosed', (event) => {
const { mode } = event.detail;
// e.g. send an analytics event
});Chat message sent
strutfit:chatMessageSent fires each time the shopper sends a message in the chat. detail.source says where the message came from. The message text itself is not included.
| Event name | When it fires | detail |
|---|---|---|
strutfit:chatMessageSent | The shopper sent a chat message | { source } |
source | Sent by |
|---|---|
'chatInput' | The shopper typed it into the chat's text field |
'suggestionBubble' | One of the suggested questions shown under a reply |
'guidedFlowButton' | The guided product search button |
'guidedFlowOption' | An answer option in the guided product search |
'orderTrackingButton' | The track my order button |
'openAssistant' | A question passed to openAssistant, including from the chat bot suggester |
Questions from the chat bot suggester are reported as 'openAssistant' whether the shopper tapped a suggested question or typed their own. Listen for strutfit:chatBotSuggesterClicked as well if you need to tell those apart.
window.addEventListener('strutfit:chatMessageSent', (event) => {
const { source } = event.detail;
// e.g. send an analytics event
});Chat product result clicked
strutfit:chatProductResultClicked fires when the shopper clicks a product result card in the chat, just before the product page opens in a new tab.
| Event name | When it fires | detail |
|---|---|---|
strutfit:chatProductResultClicked | The shopper clicked a product result card in the chat | { productName, productPageUrl, colour } |
colour is the name of the colour swatch selected on the card, or null if the product has no colours. Cards without a product page link are not clickable, so they never fire this event. Unlike the component click events, it cannot be cancelled.
window.addEventListener('strutfit:chatProductResultClicked', (event) => {
const { productName, productPageUrl, colour } = event.detail;
// e.g. send an analytics event
});Measurement codes updated
These fire when the shopper's active measurement code changes, for example after they complete a scan or switch profile.
| Event name | When it fires | detail |
|---|---|---|
strutfit:footMCodeUpdated | Active footwear measurement code was updated | { mCode, ...footMeasurements } |
strutfit:bodyMCodeUpdated | Active body / apparel measurement code was updated | { mCode } — string or null |
strutfit:tryonMCodeUpdated | Active try-on measurement code was updated | { mCode } — string or null |
mCode is null when the active code is cleared.
The foot event's detail also has the shopper's foot measurements in millimetres: leftLength, leftMaxWidth, rightLength, rightMaxWidth, longestFootLength and longestFootMaxWidth. Each is undefined when that measurement isn't available, for example when the code was cleared or its measurements couldn't be loaded.
window.addEventListener('strutfit:footMCodeUpdated', (event) => {
const { mCode, longestFootLength, longestFootMaxWidth } = event.detail;
// mCode is the new active foot M-code, or null if cleared
});The body and try-on events work the same way.
To get a shopper's foot measurements without a product, call window.StrutFit.openAssistant('sizing:footwear'), which doesn't take a product code. Once they finish a foot scan or answer the usual size questions, the assistant shows their measurements and strutfit:footMCodeUpdated fires with them. See Foot Sizing Without a Product for a full walkthrough.
Size profile updated
strutfit:sizeProfileUpdated fires when a change affects the shopper's recommendation without changing their measurement code — for example, answering the sizing questions on the assistant's results screen.
| Event name | When it fires | detail |
|---|---|---|
strutfit:sizeProfileUpdated | The shopper's sizing profile changed without their M-code changing | none |
Any size you read from StrutFit before this event may be out of date, so re-query it. strutfit-size-button already does, and emits strutfit:sizeUpdated if its size changes.
window.addEventListener('strutfit:sizeProfileUpdated', () => {
// any size StrutFit resolved before now may be out of date
});Unique user ID updated
strutfit:uniqueUserIdUpdated fires when the shopper signs in to or out of their StrutFit account in the assistant.
| Event name | When it fires | detail |
|---|---|---|
strutfit:uniqueUserIdUpdated | The shopper signed in to or out of their StrutFit account | { id } — string or null |
id is the shopper's StrutFit user ID, or null once they sign out.
window.addEventListener('strutfit:uniqueUserIdUpdated', (event) => {
const { id } = event.detail;
// id is null when the shopper signed out
});Language updated
strutfit:languageUpdated fires when the StrutFit language is first resolved on page load, when the script's data-language attribute changes, and when the shopper picks a language in the assistant.
| Event name | When it fires | detail |
|---|---|---|
strutfit:languageUpdated | The StrutFit language was set or changed | { language } |
language is StrutFit's internal numeric language identifier rather than a language code, so treat this event as a signal to re-render any StrutFit text you show rather than reading the value. It may fire more than once with the same language during page load.
window.addEventListener('strutfit:languageUpdated', () => {
// re-render any StrutFit-driven text
});Component events
These are dispatched by the individual StrutFit web components, and only fire on pages where that component is rendered.
Component click events
Each interactive StrutFit component dispatches a click event when a shopper activates it — by mouse click or by keyboard (Enter or Space). A disabled component does not fire one. strutfit-fit-tip displays text rather than being interactive, so it has no click event.
| Event name | Component | detail |
|---|---|---|
strutfit:sizeButtonClicked | strutfit-size-button | { id, productCode } |
strutfit:sizeChartButtonClicked | strutfit-size-chart-button | { id, productCode } |
strutfit:tryonButtonClicked | strutfit-tryon-button | { id, productCode } |
strutfit:chatBotBubbleClicked | strutfit-chat-bot-bubble | { id, mode } |
strutfit:chatBotButtonClicked | strutfit-chat-bot-button | { id, productCode, mode } |
strutfit:chatBotSuggesterClicked | strutfit-chat-bot-suggester | { id, productCode, mode, question } |
The chat components carry mode, the assistant mode the click is about to open, which is always 'chat'. The chat bubble is not tied to a product, so it has no productCode. The chat bot button and suggester send an empty string as productCode when none is set.
The chat bot suggester fires its event when the shopper clicks a suggested question, or sends their own from its text field with the send button or Enter. question is the text being asked, and is an empty string if the shopper sent an empty text field.
Every click event is cancelable. Calling preventDefault() stops StrutFit opening the assistant, so your storefront can handle the click itself. Leave the event alone if you only want to observe clicks.
window.addEventListener('strutfit:sizeButtonClicked', (event) => {
const { id, productCode } = event.detail;
if (shopperNeedsToPickAColourFirst) {
event.preventDefault(); // the assistant will not open
showColourPicker();
}
});Component ready events
Each StrutFit web component dispatches a ready event once it has loaded its configuration and determined that it should be visible. The event fires at most once per component instance.
| Event name | Component | detail | Global array |
|---|---|---|---|
strutfit:sizeButtonReady | strutfit-size-button | { id } — string | window.StrutFit.sizeButtonsReady |
strutfit:fitTipReady | strutfit-fit-tip | { id } — string | window.StrutFit.fitTipsReady |
strutfit:chatBotBubbleReady | strutfit-chat-bot-bubble | { id } — string | window.StrutFit.chatBotBubbleReady |
strutfit:sizeChartButtonReady | strutfit-size-chart-button | { id } — string | window.StrutFit.sizeChartButtonsReady |
strutfit:tryonButtonReady | strutfit-tryon-button | { id } — string | window.StrutFit.tryonButtonsReady |
strutfit:chatBotButtonReady | strutfit-chat-bot-button | { id } — string | window.StrutFit.chatBotButtonsReady |
strutfit:chatBotSuggesterReady | strutfit-chat-bot-suggester | { id } — string | window.StrutFit.chatBotSuggestersReady |
Because the event may fire before your listener is registered, each component also pushes its element id into the global array listed above. Check the array first for components that are already ready, then listen for the event to catch the rest.
The chat bot suggester's ready event fires once its questions have loaded and it is visible, so it does not fire at all for a product with no suggested questions.
// 1. Check for components that are already ready
const alreadyReady = window.StrutFit?.sizeButtonsReady ?? [];
alreadyReady.forEach((id) => {
// handle already-ready component
});
// 2. Listen for components that become ready later
window.addEventListener('strutfit:sizeButtonReady', (event) => {
const { id } = event.detail;
// handle newly ready component
});The same pattern applies to every ready event — substitute the event name and global array.
Size updated
Every strutfit-size-button dispatches strutfit:sizeUpdated whenever the size it resolves for its product changes — once the product config first loads, and again after the shopper updates their measurement code or answers the assistant's sizing questions. Use it to persist the recommendation, for example as a hidden line item property on the add-to-cart form.
| Event name | When it fires | detail |
|---|---|---|
strutfit:sizeUpdated | A size button resolved a new size for its product | { id, productCode, size, unit, width, sizeText } |
size, unit and width are what the button renders. Apparel products only ever populate size and sizeText. sizeText is the three parts joined with spaces and blanks dropped, e.g. 9 US D or M. When the shopper has no size for the product, size, unit and width are null and sizeText says why:
sizeText | Meaning |
|---|---|
'9 US D' | The shopper has a recommended size — the same text the button renders |
'Unavailable' | The shopper has been sized, but the product is not available in their size |
null | The shopper has not been sized yet, so the button still shows its pre-login text |
'Unavailable' is a fixed, untranslated value so it stays stable for reporting, even though the button itself renders a localised message in the same state.
Like the ready events, this may fire before your listener is registered, so each button also records its latest result on window.StrutFit.recommendedSizes.
// 1. Read any sizes that resolved before this script ran
const alreadyResolved = window.StrutFit?.recommendedSizes ?? [];
alreadyResolved.forEach((recommendedSize) => {
// recommendedSize.sizeText, e.g. '9 US D'
});
// 2. Listen for later updates
window.addEventListener('strutfit:sizeUpdated', (event) => {
const { productCode, sizeText } = event.detail;
// sizeText is 'Unavailable' when the product has no size for the shopper, null when unsized
});