YOUR_ID is replaced by your calculator's ID when you copy from Finalize.
The calculator remembers the visitor's items on your site for 7 days, in their browser (what is kept: section 07). To turn that off, add memory=0 to the script address: embed.js?id=YOUR_ID&memory=0. A shared plan link still works.
2Paste
Paste it into the page
In your site editor (WordPress, Shopify, Wix, and so on), paste the code where the calculator should appear: your unit sizes, rates or booking page. Your platform is covered in section 05.
3Publish
Publish
Save and publish. The calculator appears and sizes itself. Change colors, sizes and wording later from the dashboard, without touching the code.
Terms used in this guide
Embed code (snippet)The short line you copy. It loads the calculator into your page.
iframeThe frame inside your page that displays the calculator. The code creates it for you.
Three checks, or nothing shows up.
If one is missing, your page stays empty or shows a message. Check them before you publish.
Pre-launch check3 / 3
01
Your page is on https
The calculator only displays on an https page. On http the frame stays empty, with a CSP error in the console.
YEShttps://www.your-site.com/unit-sizes
NOhttp://www.your-site.com/unit-sizes (page without https)
OtherwiseThe frame stays empty, with a CSP error in the browser console.
Where to fix itYour host or platform: turn on the https certificate for your site.
02
Your address is declared
It only displays on three addresses: the website address from step 1, the additional URL and your company website. Anywhere else, the “Unauthorized Domain” screen appears.
YESyour-site.com
NOyour-site.webflow.io (not declared)
Where to fix itStep 1, “Where will it live?”: website address and additional URL.
03
Your calculator exists
If the calculator was deleted or the code points to one that doesn't exist, the page shows “Calculator not found” (in English). Your plan never hides a calculator from your visitors.
Where to fix itDashboard: check that the calculator is still in your list.
Size this container with plain CSS: section 06, Adjust the width.
Full width, automatic height.
The calculator always takes 100% of its container's width, so there is no width attribute to set. It sends its real height to the page and the code adjusts it live, at every step of the visitor's journey. Nothing to do on your side.
Starting heights, before the first adjustmentWidth: 100%
Mobile1200 px
Tablet900 px
Desktop800 px
< 640 px≥ 640 px≥ 1024 px
Starting heights, before the first adjustment
Mobile
< 640 px
1200 px
Tablet
≥ 640 px
900 px
Desktop
≥ 1024 px
800 px
Your platform, same line.
It's the same line everywhere. Only the spot where you paste it changes.
Platform 013 steps
WordPress
Open the page in the editor.
Add a “Custom HTML” block (Gutenberg) or an HTML widget (Elementor, Divi).
Paste the code, then update the page.
Good to knowIf your theme strips <script> tags, use a plugin such as Insert Headers and Footers.
Platform 023 steps
Shopify
Open the template where the calculator should appear (for example page.liquid).
Paste the code where you want it.
Save.
Good to knowFor a product page: paste the code into the product description, with the editor in HTML mode.
Platform 033 steps
Wix
Add an Embed Code element (Embeds, then Embed HTML).
Paste the code into the element.
Resize the element, then publish.
Good to knowSet the element's size in the Wix editor.
Good to knowWix's Embed HTML element loads the calculator from another domain. Declare it as an additional URL (step 1), or the page shows “Unauthorized Domain.”
Platform 043 steps
Webflow
Add an Embed element where the calculator should go.
Paste the code into the element.
Publish to staging or to production.
Good to knowThe calculator doesn't render inside the Webflow Designer, only on the published site.
Good to knowYour staging address (*.webflow.io) shows “Unauthorized Domain” until declared as an additional URL (step 1). Otherwise, test on the published site.
Platform 053 steps
Framer
Insert a Code Component or an HTML embed.
Paste the code.
Publish.
Good to knowSizing follows the Framer frame the embed sits in.
Platform 063 steps
Any HTML site
Open the page's HTML file.
Paste the line exactly where the calculator should appear.
Put the page online.
Good to knowThe page must be on https (section 02).
Limit it, center it: plain CSS.
To cap the maximum width or center the calculator, style the parent container:
postMessage eventsThe calculator talks to your page
The calculator talks to your page through postMessage. Listen for these events on window:
EventWhenPayload
SPACEFIT_IFRAME_READYThe calculator has loaded.No data.
SPACEFIT_RESIZEThe content height changes.{ height }, handled by embed.js.
SPACEFIT_CALCULATEDOnce per finished calculation.Volume, items, 1 to 3 recommended units. No personal data.
Listener · JavaScript
window.addEventListener('message', (event) => {
if (event.origin !== 'https://www.spacefit.co') return;
const frame = document.querySelector('iframe[src*="spacefit.co/fit/"]');
if (!frame || event.source !== frame.contentWindow) return;
const data = event.data || {};
switch (data.type) {
case 'SPACEFIT_IFRAME_READY':
// The calculator has loaded
break;
case 'SPACEFIT_RESIZE':
// Content height ({ height }): embed.js handles it
break;
case 'SPACEFIT_CALCULATED':
// Calculation finished (version 1):
// { version: 1, calculator, volume_m3, items_count, multi_box,
// recommended: [{ label, size_sqm, width_m, depth_m, height_m, unit_type? }],
// lang }
// recommended: 1 to 3 units, best first.
console.log('Calculation', data);
break;
}
});
Origin ruleSPACEFIT_CALCULATED is only sent to an https page located on your calculator's website address or additional URL. Other pages receive nothing. Always check event.origin before trusting the content.
Data kept on the visitor's deviceKeys, content, lifetime
The calculator and the floating button keep these entries on the visitor's device: the first six under your site's address, the last three inside the calculator (address www.spacefit.co). None holds a name, an e-mail or contact details. The plan is item ids and quantities; the session id is a random identifier sent with the calculator statistics; the country comes from the visitor's IP address. You can copy this table into your cookie policy.
KeyContentLifetimeWhy
spacefit:<ID>:planlocalStorageItem ids and quantities (encoded), the chosen unit, calculated or not, a timestamp.7 days after the last change or the last reopened result: each one restarts the 7 days.Reopens the calculator where the visitor left off, on every page.
spacefit:<ID>:recolocalStorageThe name and size of the recommended box and a timestamp.30 days.The floating button shows the visitor's size.
spacefit:<ID>:minsessionStorageThe value 1.Until the tab is closed.A folded card stays folded.
spacefit:<ID>:blockedsessionStorageThe value 1.Until the tab is closed.This address is not allowed for the calculator: the card stays away for the visit.
spacefit:<ID>:previewedsessionStorageThe value 1.Until the tab is closed.A preview that failed to start is not tried again during the visit.
spacefit:<ID>:cfgsessionStorageThe button settings from your dashboard (on or off, side, hidden pages, phone offset) and a timestamp.Reused for 5 minutes, kept until the tab is closed.Saves asking for the settings on every page.
analytics_session_idsessionStorageA random id, inside the calculator (address www.spacefit.co).Until the tab is closed.Counts calculator visits in your statistics.
spacefit_geo_locationlocalStorageThe visitor's country (found from their IP address by www.spacefit.co), its currency, a timestamp and the source.24 hours, then asked again.Language and currency of the calculator.
spacefit:stale-chunk-reload-atsessionStorageA timestamp.Until the tab is closed.Written only after a failed load: the calculator reloads once, never in a loop.
On spacefit.co only, the demo button uses the same keys with spacefit:demo: in front. Never on your site.
To keep no plan at all, add memory=0 to the embed.js address (sections 01 and 08).
Floating button: the calculator on every page.
Rather than a calculator inside one page, a small card in a corner of every page. One click opens the calculator over the page.
Paste this <script> tag once, in the template shared by all your pages (header or footer). launcher=1 turns on the card.
Switch the card on or off and choose its side, left or right, from your dashboard, on your calculator's Integration page. Nothing to change on your site: it picks up the change within a few minutes.
Is the same calculator already embedded in the page? Then the button scrolls down to it instead of opening it on top, and the card steps aside while the calculator is on screen.
After a calculation, the card shows the visitor their recommended size on every page of your site, for 30 days, on that device.
The calculator also remembers the visitor's items, and their result if they calculated, for 7 days, in the visitor's browser only: on the next page they pick up where they left off. Start over clears it.
For a button without plan memory, add memory=0 here too: embed.js?id=YOUR_ID&launcher=1&memory=0.
The card follows the visitor across your site, so every address where it shows must be declared (section 02). With or without www counts as the same address; another subdomain (shop.your-site.com) must be declared too, or covered by *.your-site.com.
Strict Content Security Policy? Besides script-src, also allow https://www.spacefit.co in connect-src, frame-src and img-src: the card reads its settings, its preview and its image there. Blocked, it still shows, but ignores the dashboard settings.