Paste one line. The calculator is live.

Copy the code from the Finalize step of your calculator, paste it into your page, and publish. The calculator fills the full width and adjusts its own height.

Contents1 line of HTML
Steps3
To check3 points
Code to writeNone
Send to my web developerGuide, code and the address to declare

In your colorsThe calculator appears inside your page. Visitors stay on your site.

Three steps, no code to write.

The embed code is a single line. It loads the calculator exactly where you paste it.

  1. 1Copy

    Copy the code

    In your calculator, open the Finalize step and click “Copy Code.” It looks like this:

    Code to paste · 1 line
    <script src="https://www.spacefit.co/embed.js?id=YOUR_ID"></script>
    Send to my web developerGuide, code and the address to declare

    YOUR_ID is replaced by your calculator's ID when you copy from Finalize.

  2. 2Paste

    Paste it into the page

    Open your site editor (WordPress, Shopify, Wix, and so on) and paste the code where the calculator should appear: your unit sizes, rates or booking page. Your platform is covered in section 05.

  3. 3Publish

    Publish

    Save and publish. The calculator appears and sizes itself. You can change your 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 any of these three is missing, your page stays empty or shows a message instead of the calculator. Check them before you publish.

Pre-launch check3 / 3
01

Your page is on https

The calculator only displays on a page served over https. On an http page the frame stays empty and the browser console shows a CSP error.

  • 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

The calculator only displays on three addresses: the website address you set in step 1, the additional URL and your company website. Anywhere else, the page shows the “Unauthorized Domain” screen.

  • 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 a “Calculator not found” screen (in English). Your plan never hides a calculator from your visitors.

Where to fix itDashboard: check that the calculator is still in your list.
All three good? Paste the code.Where to put it, section 03

Right where you paste it, nowhere else.

The code inserts the calculator exactly where the <script> tag sits. To control that spot, put it inside a container:

Container · HTML
<div class="my-calculator-wrapper">
  <script src="https://www.spacefit.co/embed.js?id=YOUR_ID"></script>
</div>

You size this container with plain CSS: see section 06, Adjust the width.

Full width, automatic height.

The calculator always uses 100% of its container's width, so there is no width attribute to set. Its height follows its content: 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%
Starting heights, before the first adjustment
Mobile< 640 px1200 px
Tablet≥ 640 px900 px
Desktop≥ 1024 px800 px

Your platform, same line.

It's the same line everywhere. Only the spot where you paste it changes.

Platform 013 steps

WordPress

  1. Open the page in the editor.
  2. Add a “Custom HTML” block (Gutenberg) or an HTML widget (Elementor, Divi).
  3. 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

  1. Open the template where the calculator should appear (for example page.liquid).
  2. Paste the code where you want it.
  3. Save.

Good to knowFor a product page: paste the code into the product description, with the editor in HTML mode.

Platform 033 steps

Wix

  1. Add an Embed Code element (Embeds, then Embed HTML).
  2. Paste the code into the element.
  3. Resize the element, then publish.

Good to knowThe embed element's size is set in the Wix editor: resize it to fit your layout.

Good to knowWix's Embed HTML element loads the calculator from another domain. Declare that domain as an additional URL (step 1), otherwise the page shows “Unauthorized Domain.”

Platform 043 steps

Webflow

  1. Add an Embed element where the calculator should go.
  2. Paste the code into the element.
  3. 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 you declare it as an additional URL (step 1). Declare it, or only test on the published site.

Platform 053 steps

Framer

  1. Insert a Code Component or an HTML embed.
  2. Paste the code.
  3. Publish.

Good to knowSizing follows the Framer frame the embed sits in.

Platform 063 steps

Any HTML site

  1. Open the page's HTML file.
  2. Paste the line exactly where the calculator should appear.
  3. 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:

Container · CSS
.my-calculator-wrapper { max-width: 960px; margin: 0 auto; }

Don't set a height on the container. It conflicts with the calculator's automatic height adjustment.

For developers.

Advanced · for developers

Not technical? You can safely skip this section.

Content Security PolicyCSP · script-src and frame-src

If your site uses a Content Security Policy, allow https://www.spacefit.co: the script and the calculator page load from that origin.

CSP header
script-src 'self' https://www.spacefit.co; frame-src 'self' https://www.spacefit.co;
postMessage eventsThe calculator talks to your page

The calculator talks to the host 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_CALCULATEDComing soon: this event isn't shipped yet.Once 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 host page located on your calculator's website address or additional URL. Other pages receive nothing. Always check event.origin before trusting the content.

One symptom, one fix.

Start with the three checks in section 02: they are the easiest causes to fix.

SymptomAn error screen instead: Unauthorized Domain
CauseYour page's address isn't declared: a subdomain, a staging site, a Wix Embed element, or a page that hides its origin (no-referrer).
FixDeclare that address in step 1, “Where will it live?”: website or additional URL (section 02).
SymptomNothing shows up, the script isn't in the published page
CauseYour CMS stripped the <script> tag.
FixCheck that the line is in the published page. On WordPress, use a plugin such as Insert Headers and Footers.
SymptomThe frame stays empty
CauseThe page isn't on https (CSP error in the console).
FixServe the page over https (section 02).
SymptomAn error screen instead: Calculator not found
CauseThe calculator was deleted, or the code points to one that doesn't exist.
FixCheck that the calculator is still in your dashboard, then copy the code again from the Finalize step.
SymptomNothing shows up, error in the console
CauseYour Content Security Policy blocks spacefit.co.
FixAllow script-src and frame-src for https://www.spacefit.co (section 07).
SymptomNothing shows up, no error
CauseThe id parameter doesn't match your calculator.
FixCopy the code again from the Finalize step, without editing it.
SymptomToo short or too tall
CauseA height is set on the container.
FixRemove the height and let the calculator adjust. If you really need a limit, put it in a div with overflow:auto.
SymptomInvisible for some visitors
CauseAn aggressive ad blocker blocks third-party iframes.
FixAsk those visitors to turn off their blocker on your domain.

Stuck? We'll help.

Write to us or book a call and we'll look at your page with you.

HelpSpaceFit Support

By email

Send your page address and what you see instead of the calculator. A screenshot helps a lot.

support@spacefit.co

15-minute call

Book a time slot, or do it from the Finalize step of your calculator.

Book a call
SF-HELP
Fragile · This side up · SpaceFit · Free, no card
For: your websiteNo calculator yet?

Build it, then paste the line.

Your furniture, your units, your colors: you set the calculator up in the dashboard, and the code is waiting in the Finalize step.

Free, no card.
SF-0912