Skip to content

Website badge

Add StayParity's book-direct badge to a hotel's website with one snippet. The snippet, the dock, what guests see, and the CSP it needs.

The badge is a small price box on the hotel's own website. It shows the direct price for a stay and, when the hotel is cheapest or level, the OTA prices beside it. It runs in a sandboxed iframe, so it can't read the page it sits on and the page can't reach into it. The sandbox lets it do two things, each only on a guest's click: open the hotel's booking page in the tab the guest is on, and open stayparity.com in a new tab from its credit link.

What the badge says to guests, and why, is on The book-direct badge. This page is about putting it on a site.

Add it to a page

  1. In the portal, go to Settings → Website badge and turn Badge on. The portal asks for the hotel's booking page, which stays on the same screen under Booking page to change later. The Book direct button, in the guest's language when translation is on, opens the booking page in the same tab.
  2. Copy the snippet from the Snippet group, under Paste: the script tag, which holds the hotel's embed key and nothing else. Tag manager gives the same tag, with the steps for a Custom HTML tag. Pass it on gives a message with the snippet, where it goes and how to check it, to send whoever looks after your website.
  3. Paste it once on each page that should show the badge, or in your site's footer. The badge floats in a bottom corner of the window wherever the tag sits, so it can go anywhere in <body>. Then run Check my site on the portal's Badge page with the page's address: it says whether the tag is on the page and whether your site's security policy lets the badge load.
The snippet
<!-- StayParity book-direct badge. Its look is set in StayParity. -->
<script src="https://badge.stayparity.com/embed.js" data-hotel="wk_aurora" async></script>

The script puts an iframe at the end of the page and touches nothing else on it. The frame sets its own height to fit what it shows.

The dock

The badge is a dock: a bar in a bottom corner of the window that appears once the direct price arrives. A click opens it into a card with the full answer, and the chevron at the card's foot, or Escape, folds it shut again. The guest can't close it: it stays for the rest of the page view. Where a chat button or a sticky booking bar already floats in its corner, the dock lifts above it or moves to the other bottom corner, and stays where it is when neither is clear. It hides while a common cookie banner stretches across it.

Under Appearance in Settings → Website badge:

  • Dock corner picks the left or right corner, and Dock lift how far above the window's bottom edge it sits, up to 200 pixels.
  • Button colour is Auto, dark on a light surface and light on a dark one, or a colour of your own. A colour that stands out less than 3:1 against the surface is refused.
  • Surface is Light, Dark or Guest's system, which follows the guest's light or dark setting.
  • Corners are Square, Rounded or Pill.

Every change reaches each page with the tag within a minute, with the same snippet. The badge asks StayParity for its settings on every page load.

Language

The badge speaks English. Turn on Translate the badge in Settings → Website badge and it speaks the guest's language instead when their browser prefers Greek, Spanish, Italian, German or Czech, and English otherwise. It goes by the languages set in the guest's browser, not the language of your page, and writes prices and dates the way that language does. It is off until you turn it on, and it reaches every page with the tag within a minute, with no new snippet.

Currency

The badge shows prices in the hotel's own currency. With Guests can change currency on, a currency code in the dock's footer opens a menu of the currencies you offer, the hotel's first, and every price on the card switches to the one the guest picks, converted at the day's reference rate. The comparison itself, and what the booking page charges, stay in the hotel's currency. With Open in the guest's currency on, the badge starts in the currency of the guest's region, read from their browser's language, when you offer it.

Options

The tag takes two attributes:

  • data-hotel, required: the hotel's embed key, wk_…. Without it the tag renders nothing.
  • data-consent="none", optional: StayParity leaves that page view out of the badge's counts, and the badge stores nothing in the guest's browser, so Keep this night, Open by itself and the exit offer don't show on that page and test mode lasts one page. The prices it shows don't change. To keep the badge off a page until the guest consents, load the tag from your consent or tag manager instead.

Its look, language and currency come from StayParity, and the night from the page.

Which night it prices

The badge prices one night: the check-in date, with its check-out date or number of nights, and the number of adults your guest picks. It finds them only in your page's address, in your booking form's fields and, on Mews and Cloudbeds booking pages, in the events those engines push to the page's dataLayer, and reads nothing else on the page. Until it knows a stay, it shows the soonest night of the coming week that we priced in the last day, while Nearest priced night is on, as it is from the start. With that setting off, or with no such night, it shows nothing and takes no space. For a stay with no number of adults, or with children or more than one room, it shows the price for two adults, or for the smallest number the hotel is checked for when two isn't one of them. It shows the guest's own night as soon as it knows the stay, for example the moment a guest picks dates in your booking form.

The badge starts a fresh check only for the occupancies the hotel is monitored on. For any other, it shows a price already read for it, or else the price for two adults, or for the smallest number the hotel is checked for, and says so.

What it reads:

  • The page's address, as the page loads and whenever it changes, as it does when a booking engine searches without reloading the page. Check-in from checkin, checkInDate, arrival, arrivalDate, arrive, startDate, dateFrom, fromDate or mewsStart; check-out from checkout, checkOutDate, departure, departureDate, depart, endDate, dateTo, toDate or mewsEnd; nights from nights or los; adults from adults, adult, adultCount, adultQty, numAdults, numberOfAdults or mewsAdultCount; children from children, child, childCount, childQty, kids or numChildren; rooms from rooms, numRooms or roomCount. Case and punctuation don't matter, so check_in and Check-In count, but the whole name must match: in or items[0][adults] reads nothing. A total of guests, such as guests, pax, persons or occupancy, never counts as adults.
  • Your booking form's fields, once the guest changes one. A field counts when its name, its id or the last [...] part of its name is one of the names above, such as arrival_date or info[arrival_date]. It never reads a hidden, password, email, phone, file, checkbox or radio field, a field the browser fills with a name, email, phone number or card, or a disabled field. A form as it loaded counts only once the guest changes one of its fields, so a form that opens with tonight's date filled in leaves the nearest priced night showing until the guest picks.

The latest stay it reads wins, wherever it comes from. An address that holds only a booking engine's defaults, one night from today for two adults, counts only once it changes. The first night it knows is checked at once. After that, the badge waits half a second after the guest's last change before it asks again, so a date picker that sets two fields costs one check. A picker that writes its fields without a change event is read 300 milliseconds after the guest's click.

It reads dates written as 2027-06-14, 2027/06/14, 20270614, 14/06/2027 or 06/14/2027 (with /, . or -), and as 14 Jun 2027 or Jun 14, 2027, with month names in the badge's six languages and French. A numeric date that reads two ways and gives two possible stays is skipped. A stay is 1 to 30 nights, between today and 500 days ahead. It doesn't read forms inside another frame or a shadow root, or date and guest pickers that aren't form fields.

If your booking form runs in its own frame, or uses date and guest pickers that aren't form fields, the badge can't see the night: it shows the nearest priced night, or nothing with Nearest priced night off. Put the stay in the page's address instead, such as ?checkin=2027-06-14&checkout=2027-06-15&adults=2.

What guests see

The badge compares the direct price with the OTA prices for that night, and lists the OTAs only when booking direct is cheapest or the same price:

WhenTitleAlso shows
The hotel is cheapestSave €16Each OTA's price for the same stay
The hotel matches the cheapest OTA to the centSame price, booked directEach OTA's price for the same stay
An OTA is cheaperThe direct price, such as €188 per nightNo OTA
No OTA price for that nightThe direct price, such as €188 per nightNo OTA

Folded, the dock reads Save €16 by booking direct, Same price as Booking.com, or, with no OTA to list, Best price here: €188 per night.

The card opens on one row with the night it priced, such as Night of Sat 4 Oct · 2 adults or Tonight, and how long ago the prices were checked, such as Checked 12 min ago (left out once the check is a week old). Under it, a seal says Best price here on every verdict, above the title. When the badge lists the OTAs, they are under Same stay elsewhere, each with its logo, name and price. The Book direct button carries the night's direct price. At the card's foot, Price check by StayParity links to stayparity.com in a new tab, between the chevron that folds the card and, when you let guests change currency, the currency switch.

To count the bookings Book direct sends in your own analytics, read Measure the badge in your analytics. To quote the same answer in a chat bot or a widget of your own, read Price check API.

While the first check for a stay runs, and if no price arrives, the dock shows nothing. The badge shows nothing and takes no space when:

  • the hotel is inactive in StayParity.
  • no price has been read for the stay, a check is refused (the stay is in the past or further ahead than the hotel's plan checks, or the hotel's allowance of checks is used up), and two adults, or the hotel's smallest checked number, has no price either.

Prices are formatted for the guest's locale, in the hotel's currency or the one the guest switches to. The badge's words are in English, or in the guest's language when translation is on.

What it never shows

  • An OTA price below the hotel's own, or even that there is one. When an OTA is cheaper, the dock shows the direct price alone rather than listing only the dearer ones. The API never discloses an undercut either: it answers that night exactly as it answers one no OTA sells, so neither a guest nor a script reading the endpoint can tell the two apart. The hotel still gets the undercut in the portal and in its alerts.
  • The hotel's internal id, where a price was read, or how sure we are of it.
  • An error. The frame takes no space while the first check runs, and stays hidden if the check fails. If the key is unknown or the badge is off, the frame collapses to zero height and leaves no gap on the page. A guest's browser may keep showing a badge it loaded in the last five minutes.

What it stores on the guest's device

The frame and the script set no cookies. With the hotel's extra switches off, they store nothing in the guest's browser. Keep this night, Open by itself and the exit offer each keep a small note on the guest's device, in your page's storage, under the hotel's embed key:

  • Keep this night: the night and the number of adults the guest kept, in localStorage, written when they tap Keep. The badge removes it when they tap Kept again, and on their next visit to a page where your badge loads once its check-in has passed or the switch is off.
  • Open by itself and the exit offer: in sessionStorage until the tab closes, a note written when the dock opens by itself or on a leave, or when the guest folds it, so it doesn't open by itself again.
  • The exit offer: in sessionStorage until the tab closes, a note written when the offer shows or the guest follows Book direct, so a leave doesn't show it again. In localStorage, the time the guest closed the offer, so it stays closed for 7 days. The badge removes that one on their next visit to a page where your badge loads after the 7 days, or once the offer stops showing: switched off, or no code live.

Your cookie banner or consent setup may need to cover these notes. Under data-consent="none" none of them is read or written.

Test mode (#stayparity-debug in the page's address) keeps its language in that tab's sessionStorage.

What it counts

Unless the tag has data-consent="none", the frame sends StayParity one count for each page view that showed it, when the page is hidden or closed or the guest follows Book direct. These counts are the badge's figures in the portal. The first send for a page view holds:

  • the hotel's embed key and the page's hostname;
  • the browser's language, and whether the screen is phone-sized;
  • which night the badge priced: the guest's stay, the guest's date for another number of adults, or the nearest priced night;
  • its verdict, such as booking direct is cheapest or the same price;
  • whether it is a strip or a dock, and whether test mode is on;
  • whether it drew a price and came into view, the guest opened the dock or followed Book direct, the exit offer showed, the guest copied its code or kept the night, and the dock opened by itself.

If the guest does more after that, such as copying the code, a later send carries only the embed key, the hostname and which of these the guest did. No send carries an ID, a page address or a stay date.

The edge server that receives the counts uses the guest's IP address only as the key of its rate limit, 30 sends a minute, which Cloudflare holds for that minute. It doesn't log the address or pass it on, and StayParity never stores it.

Content Security Policy

If the site sends a Content-Security-Policy header, allow the badge's origin to load the script and the frame, and the script to read the badge's settings:

script-src https://badge.stayparity.com;
frame-src https://badge.stayparity.com;
connect-src https://badge.stayparity.com;

Add these to the sources the site already allows rather than replacing them.

The script asks the badge's origin for its settings before it creates the frame, and connect-src is what allows that. Without it the badge still works, but the browser logs a CSP violation on every page view, and the frame starts at the tag, then gives way to a second one at the end of the page, so it loads twice. The script sets the frame's size through the DOM, not inline style attributes in markup, so the snippet needs no change to style-src.

The prices are fetched inside the frame, under the frame's own policy. If your script policy uses nonces or strict-dynamic, give the script tag the nonce your site uses; adding a host to the allowlist alone may not allow it.

Turn it off or replace it

  • Turn off: switch Badge off in Settings → Website badge. New visitors see nothing, as the frame shrinks away; a guest's browser may keep showing a badge it loaded in the last five minutes. Switch it back on and the same snippet works again.
  • Change its look or currency: change Appearance or the currency settings in Settings → Website badge. Every page with the tag follows within a minute, with the same snippet.
  • Translate: switch Translate the badge in Settings → Website badge. Every page with the tag follows within a minute, with the same snippet.
  • Replace: Replace snippet issues a new embed key. The old key is refused on the next uncached request, on every site that has it, until you paste the new snippet. A browser may keep showing a badge cached in the last five minutes.

Only account admins can turn the badge on or off, change its look, language or currency, or replace the snippet.

Performance

The script loads with async, so it never holds up the page. As browsers download them, compressed, the script is about 9 kB and the badge's frame about 32 kB of script more, with no web font to fetch.

Each page view gets one frame, once the page has loaded, or 3 seconds after it was parsed if that comes first, and the browser is idle, so it never competes with the page's own loading. When the site's policy leaves out connect-src, the frame starts at the tag and is replaced at the end of the page, so it loads twice.

A page whose badge is off gets no frame. Before it knows the night, the badge asks only for the nearest priced night, and for nothing with Nearest priced night off. After that it asks again only when the guest settles on another night.

On this page