Website integration

Add experiences to your site

How to put a Hullabalook experience on your web pages with hintegrate, either as a tag in your markup or from your own JavaScript.

A Hullabalook experience, such as a configurator, a room planner or a grid of recommendations, goes on your page through one script called hintegrate. You load the script once, then mark where each experience should appear. Hintegrate fetches the published version of the experience and sizes it to fit, so you don't need to change your page when we release a new version.

What you need

Your Hullabalook contact gives you two things before you start:

If you also run the Hulla Pixel, load the pixel before hintegrate so that the experience and the pixel share one shopper session.

The quickest way: a tag in your markup

Load the script once on the page, then put a <hulla-experience> element wherever the experience should appear:

<script src="https://<your-name>.hulla-cdn.com/hintegrate.js"></script>

<hulla-experience experience-label="sofa-configurator" initial-height="800"></hulla-experience>

This works in any template language or framework, because <hulla-experience> is a standard web component. The experience keeps its own styles apart from your page's styles, so neither one changes the look of the other.

AttributeRequiredWhat it does
experience-labelYesSays which experience to load. Without it, nothing is shown and an error appears in the browser console.
initial-heightNoSets the height in pixels to hold open while the experience loads, so the page doesn't jump. The experience then sets its own height.
experience-idNoGives the experience an id of its own. Use it when you put the same label on one page twice and want to tell the two apart in events.
inlineNoAsks for the experience to run inside your page rather than in a frame. See Running inline.

Passing settings to the experience

Settings that don't fit in an attribute go in a JSON block inside the element:

<hulla-experience experience-label="recommended-products" initial-height="600">
  <script type="application/json">
    {
      "params": { "grid_id": "homepage" },
      "containerParams": { "title": "Products picked for you" }
    }
  </script>
</hulla-experience>
SettingWhat it does
paramsPasses values to the experience, such as which grid or which range to show. Your Hullabalook contact tells you which ones an experience reads.
pageConfigChooses a prepared version of an experience, for experiences that have them.
containerParamsSets attributes on the frame that holds the experience. Set a title so that screen readers can describe the experience.

If the JSON is not valid, the experience still loads without these settings, and the browser console shows the parsing error.

From your own JavaScript

If your page builds its content in JavaScript, call hintegrate yourself. The element you mount into needs the class hulla and an id that is unique on the page:

<script src="https://<your-name>.hulla-cdn.com/hintegrate.js"></script>

<div class="hulla" id="sofa"></div>
<script>
  HIntegrate.initialiseExperience("sofa-configurator", "#sofa", {
    initialHeight: 800,
    params: { range: "harbour" },
  });
</script>

HIntegrate.initialiseExperience(label, selector, options) takes the same settings as the tag. The options are initialHeight, params, pageConfig, containerParams and inline. Call it only after the script has loaded. If the selector matches nothing on the page, the call throws an error.

Choosing experiences by product

On a product page you might know the product's SKU but not which experiences cover it. HIntegrate.initialiseExperienceFromSku looks the SKU up and mounts each matching experience in the place you give it:

HIntegrate.initialiseExperienceFromSku("SKU-12345", [
  { experienceType: "configurator", container: "#configurator", isDevelopmentExperience: false, initialHeight: 800 },
  { experienceType: "recommended-products", container: "#recommended", isDevelopmentExperience: false },
]);

If no experience covers the SKU, nothing is mounted and the page is unchanged.

Checking for a product first

To show a button only when an experience has a given product, ask before you mount anything. HIntegrate.productExistsInExperience(label, productId) returns true or false, and HIntegrate.getProductInExperience(label, productId) returns the product's details, or null if it is not there.

More than one experience on a page

A page can hold as many experiences as you like. Give each one its own element, and each sizes itself independently:

<hulla-experience experience-label="sofa-configurator"></hulla-experience>
<hulla-experience experience-label="recommended-products"></hulla-experience>

When you call hintegrate from JavaScript, give each container its own id.

How the experience talks to your page

An experience sometimes needs your page to do something, such as add products to the basket or open your own sign-in. It asks through a small file of handlers that we write with you for your site. Hintegrate loads that file next to the experience, and only accepts messages from frames served from hulla-cdn.com.

If you would rather bundle those handlers yourself, add ?loadJs=false to the script address. You then load the handler files yourself, before you call hintegrate.

Running inline

By default each experience runs in a frame. Some experiences can also run inside your page itself, which removes the frame and lets the experience share your page's fonts and storage. Ask for it with the inline attribute, or with inline: true in the options:

<hulla-experience experience-label="sofa-configurator" inline></hulla-experience>

Inline is a request, not a guarantee. If the experience's current version can't run inline, or anything stops it from starting, hintegrate shows the same experience in its frame and logs one warning in the browser console saying why. The element is marked data-hulla-mode="inline" or data-hulla-mode="iframe" so that you can see which one you got.

To try inline on your live page before you switch it on, add ?hulla_inline=true to the page's address. Add ?hulla_inline=false to see the framed version on a page that has asked for inline. The address always wins over the page's own setting.

Before you go inline, check these with your Hullabalook contact:

Checking it works

Open the page with the browser's developer tools open: