This is our docs site, visit our main website at strut.fit
StrutFitStrutFit
Guides

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

EventEmitted byWhen it firesdetail
strutfit:readyAssistant ManagerStrutFit has loaded and window.StrutFit is usable{ config }
strutfit:assistantOpenedAssistant ManageropenAssistant was called{ mode, productCode }
strutfit:assistantClosedAssistant ManagerThe open assistant was closed{ mode }
strutfit:chatMessageSentAssistant ManagerThe shopper sent a chat message{ source }
strutfit:chatProductResultClickedAssistant ManagerThe shopper clicked a product result card in the chat{ productName, productPageUrl, colour }
strutfit:footMCodeUpdatedAssistant ManagerThe active footwear measurement code changed{ mCode, ...footMeasurements }
strutfit:bodyMCodeUpdatedAssistant ManagerThe active body / apparel measurement code changed{ mCode }
strutfit:tryonMCodeUpdatedAssistant ManagerThe active try-on measurement code changed{ mCode }
strutfit:sizeProfileUpdatedAssistant ManagerThe shopper's sizing profile changed without a new M-codenone
strutfit:uniqueUserIdUpdatedAssistant ManagerThe shopper signed in to or out of their StrutFit account{ id }
strutfit:languageUpdatedAssistant ManagerThe StrutFit language was set or changed{ language }
strutfit:<component>ClickedEach interactive componentThe shopper clicked or activated the componentvaries by component
strutfit:<component>ReadyEach componentThe component loaded and is visible{ id }
strutfit:sizeUpdatedSize buttonThe 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 nameWhen it firesdetail
strutfit:readyStrutFit 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 nameWhen it firesdetail
strutfit:assistantOpenedopenAssistant was called{ mode, productCode }
strutfit:assistantClosedThe 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 nameWhen it firesdetail
strutfit:chatMessageSentThe shopper sent a chat message{ source }
sourceSent 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 nameWhen it firesdetail
strutfit:chatProductResultClickedThe 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 nameWhen it firesdetail
strutfit:footMCodeUpdatedActive footwear measurement code was updated{ mCode, ...footMeasurements }
strutfit:bodyMCodeUpdatedActive body / apparel measurement code was updated{ mCode } — string or null
strutfit:tryonMCodeUpdatedActive 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 nameWhen it firesdetail
strutfit:sizeProfileUpdatedThe shopper's sizing profile changed without their M-code changingnone

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 nameWhen it firesdetail
strutfit:uniqueUserIdUpdatedThe 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 nameWhen it firesdetail
strutfit:languageUpdatedThe 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 nameComponentdetail
strutfit:sizeButtonClickedstrutfit-size-button{ id, productCode }
strutfit:sizeChartButtonClickedstrutfit-size-chart-button{ id, productCode }
strutfit:tryonButtonClickedstrutfit-tryon-button{ id, productCode }
strutfit:chatBotBubbleClickedstrutfit-chat-bot-bubble{ id, mode }
strutfit:chatBotButtonClickedstrutfit-chat-bot-button{ id, productCode, mode }
strutfit:chatBotSuggesterClickedstrutfit-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 nameComponentdetailGlobal array
strutfit:sizeButtonReadystrutfit-size-button{ id } — stringwindow.StrutFit.sizeButtonsReady
strutfit:fitTipReadystrutfit-fit-tip{ id } — stringwindow.StrutFit.fitTipsReady
strutfit:chatBotBubbleReadystrutfit-chat-bot-bubble{ id } — stringwindow.StrutFit.chatBotBubbleReady
strutfit:sizeChartButtonReadystrutfit-size-chart-button{ id } — stringwindow.StrutFit.sizeChartButtonsReady
strutfit:tryonButtonReadystrutfit-tryon-button{ id } — stringwindow.StrutFit.tryonButtonsReady
strutfit:chatBotButtonReadystrutfit-chat-bot-button{ id } — stringwindow.StrutFit.chatBotButtonsReady
strutfit:chatBotSuggesterReadystrutfit-chat-bot-suggester{ id } — stringwindow.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 nameWhen it firesdetail
strutfit:sizeUpdatedA 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:

sizeTextMeaning
'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
nullThe 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
});
2026 © StrutFit.

On this page

Question? Give us feedback