Skip to content

    Pre-launch API. The concepts described here are settled, but the API shape is not: request and response fields, parameters and defaults can still change. Build against it, and talk to your Luigi's Box contact before you put an integration into production.

    Displaying banners

    View source

    A banner with html comes back in a search or collection response as html_url: a page we host on your organization’s own subdomain of eu1.luigisboxusercontent.com, such as https://lbo-r2vn8c.eu1.luigisboxusercontent.com/banners/lbbn_7h3k9w/6f9d71fd2279e42d….html. Show it in an <iframe> in the area the response names. A banner with only metadata has no page: your front end builds it from the values.

    <div class="banner-area banner-area--above-results">
    <iframe
    src="https://lbo-r2vn8c.eu1.luigisboxusercontent.com/banners/lbbn_7h3k9w/6f9d71fd2279e42d….html"
    title="Promotion"
    sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation"
    loading="lazy"
    ></iframe>
    </div>
    • Give each area a fixed size in your layout. The page cannot resize its frame, and an area sized in advance keeps the results from moving when the banner loads.
    • The sandbox attribute repeats the isolation our server already sends with the page, so the banner stays isolated however the frame is set up.
    • title names the frame for screen readers. loading="lazy" suits areas below the fold.
    • Render the area only when banners holds a banner for it. An empty banners list, or no banner for an area, means nothing shows there.

    A frame reports no error when its page fails to load, and the page cannot report it to yours: the frame stays empty in its reserved space. This happens when:

    • your page sends a Content-Security-Policy whose frame-src or child-src does not allow https://*.eu1.luigisboxusercontent.com;
    • the banner is archived while a shopper pages through results that were chosen before; see Archiving.

    The page is served with a Content-Security-Policy sandbox, so the browser isolates it:

    • Its scripts run.
    • It has no cookies and no storage: localStorage, sessionStorage and IndexedDB are not available.
    • It cannot read or change your page, and your page cannot read it.
    • A link with target="_top" opens in your page’s tab when the shopper clicks it, and one with target="_blank" in a new tab. A link without a target opens inside the frame, so give every link one. Without a click, the frame cannot navigate your page.
    • Forms cannot be submitted.
    • Camera, microphone, location and payment are blocked.
    • Any https: page can show it in a frame; an http: page cannot.

    A wide strip above the results and a square tile in the grid can show the same banner, each through its own campaign rule. Media queries inside the frame see the frame, not the browser window, so one page can choose its picture by the shape of the area it is shown in:

    <style>
    html, body { margin: 0; height: 100%; }
    img { display: block; width: 100%; height: 100%; object-fit: cover; }
    </style>
    <a href="https://example.com/northwear" target="_top">
    <picture>
    <source media="(min-aspect-ratio: 3/1)" srcset="lbx-image:strip.jpg">
    <source media="(max-aspect-ratio: 1/1)" srcset="lbx-image:tile.jpg">
    <img src="lbx-image:card.jpg" alt="Northwear autumn: 30 % off">
    </picture>
    </a>

    Upload strip.jpg, tile.jpg and card.jpg with the banner; each lbx-image: name is replaced with its image’s URL. See Images.

    A search or collection response ends each html_url with the catalog’s language as a fragment, such as …/6f9d71fd2279e42d….html#language=de-DE, as a BCP 47 tag: the form Intl and HTML lang take, so a catalog whose language is de_DE gives de-DE. Keep the fragment when you put the URL in the frame, or set it to another language your page shows. It never reaches our server, so a banner shown in several languages loads one cached page. A script inside the banner reads it from location.hash and shows the matching text:

    <h2 id="headline">Autumn sale</h2>
    <script>
    const texts = { "de-DE": "Herbst-Sale", "fr-CH": "Soldes d'automne" };
    const language = new URLSearchParams(location.hash.slice(1)).get("language");
    if (texts[language]) document.getElementById("headline").textContent = texts[language];
    </script>

    Without a script, the banner shows the same text in every language. The html_url that /platform/v1/banners returns carries no fragment.

    • Banners — creating a banner and showing it through a campaign
    • Search and Collection — the responses that carry banners