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

Events We Emit

StrutFit dispatches a small set of window events so your storefront can react when shopper measurement state changes. The events listed here are fired by the Assistant Manager after it receives updates from the embedded assistant and persists them to local storage.

The Assistant Manager must be present on the page for these events to fire. They are not emitted by the size button or other scripts alone.

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

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; }); window.addEventListener('strutfit:tryonMCodeUpdated', (event) => { const mCode = event.detail?.mCode; });

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

Last updated on