Skip to Content
This is our docs site, visit our main website at strut.fit 
GuidesEvents We Emit

Events We Emit

StrutFit dispatches window events so your storefront can react to measurement changes and component lifecycle. Measurement-code events are fired by the Assistant Manager after it receives updates from the embedded assistant and persists them to local storage. Each StrutFit component also fires its own ready event when it loads.

Measurement code events

Each event uses a CustomEvent with detail.mCode. The value may be a string or null when the active code is cleared.

Event nameWhen it firesdetail
strutfit:footMCodeUpdatedActive footwear measurement code was updated{ mCode } — string or null
strutfit:bodyMCodeUpdatedActive body / apparel measurement code was updated{ mCode } — string or null
strutfit:tryonMCodeUpdatedActive try-on measurement code was updated{ mCode } — string or null

Under the hood, the manager handles internal assistant messages (UPDATE_FOOT_MCODE, UPDATE_BODY_MCODE, UPDATE_TRYON_MCODE), writes the corresponding fields to StrutFit user data in local storage, then dispatches the matching event on window.

Listening for measurement code events

Use window.addEventListener. Cast or narrow event to CustomEvent if you use TypeScript.

window.addEventListener('strutfit:footMCodeUpdated', (event) => { const mCode = event.detail?.mCode; // mCode is the new active foot M-code, or null if cleared }); window.addEventListener('strutfit:bodyMCodeUpdated', (event) => { const mCode = event.detail?.mCode; // mCode is the new active body M-code, or null if cleared }); window.addEventListener('strutfit:tryonMCodeUpdated', (event) => { const mCode = event.detail?.mCode; // mCode is the new active try-on M-code, or null if cleared });

Remember to remove listeners when your component or app context is torn down if you attach them in SPA code.

Component ready events

Each StrutFit web component dispatches a ready event on window once it has loaded its configuration and determined that it should be visible. The event fires at most once per component instance.

Because the event may fire before your listener is registered, each component also pushes its element id into a global array on window.StrutFit. Check the array first for any components that are already ready, then listen for the event to catch the rest.

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

Listening for ready events

// 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?.id; // handle newly ready component });

The same pattern applies to all five events — substitute the event name and global array as needed.

Last updated on