Automatic vs manual execution mode
Automatic execution mode
PerfittSize initializes itself when the page loads. This is the default unless configured otherwise.
Manual execution mode
PerfittSize runs only when you call the code below. Use it with an SPA such as React, or when you want to pass sync values directly from your code. Perfitt has to enable this mode in your project settings, so ask your Perfitt contact in advance.
How to use manual execution mode
Run the following code after the product information has rendered. You can pass sync values with it, and productId is required.
JavaScript
window.initializePerfittSize({
productId: '{{Product ID}}', // required
customerId: '{{ID of the logged-in customer}}', // only when logged in
brand: '{{Shoe brand}}',
modelNo: '{{Shoe model number}}',
gender: '{{Target gender of the shoe}}', // 'f' or 'm'
});Five values can be passed: customerId, productId, brand, modelNo and gender. See Syncing items for what each one means.
How it behaves
- Without productId, no button is drawn. A call without it only reloads the script and stops.
- Calling again with the same productId does nothing. A call with a different productId removes the previous button and draws a new one, so in an SPA call it on every navigation between product pages.
- If the configuration has not arrived yet, it retries every 0.5 s. After 10 tries (about 5 s) it gives up. With the script tag in head and a normal network, the first try usually succeeds.
- In a project without manual execution mode, nothing happens. If you called it and no button appears, ask your Perfitt contact to check that manual execution mode is turned on for your project.