The booking widget shows the UzmiTermin calendar right on your website: clients see masters, services and free time slots and book without leaving the page. The booking appears in your UzmiTermin, and notifications go out as usual. In this guide you will create a widget, add it to a page and adjust it to your website.
Sign in to your company account and open the Booking widget section on this page.
Enter the domain of the website where the widget will be placed - for example, salon.rs. The www version is allowed automatically. If you need the widget on subdomains, enter *.salon.rs: this allows all subdomains as well as salon.rs itself.
Save - the code to paste will appear.
Paste the code where the calendar should appear on the page:
<script src="https://widget.uzmitermin.rs/e/YOUR_TOKEN.js" async></script>
The widget takes the full width of the block and adapts its height to the content - there is no scrolling inside. When a client picks a time, the booking window opens over the whole page, and after booking the page stays where it was.
To place the widget in another block rather than next to the code, point to that block with the data-target attribute:
<div id="booking"></div>
<script src="https://widget.uzmitermin.rs/e/YOUR_TOKEN.js" data-target="#booking" async></script>
If the page is built with React (Next.js, Gatsby, Remix and so on), you cannot just put the <script> tag into JSX. Next.js renders the page on the server, and the widget inserts the calendar before React takes over the page. React then finds markup that differs from what the server sent and fails with a hydration error (Minified React error #418). Also, when a visitor reaches the page through a link inside the site, such a tag is not run at all.
Add the tag from code once the component is on the page:
'use client';
import { useEffect, useRef } from 'react';
export const BookingWidget = () => {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
const container = ref.current;
if(!container)
return;
const script = document.createElement('script');
script.src = 'https://widget.uzmitermin.rs/e/YOUR_TOKEN.js';
script.async = true;
// Attributes from the table below: script.dataset.lang = 'ru';
container.appendChild(script);
return () => container.replaceChildren();
}, []);
return <div ref={ref} />;
};
Place <BookingWidget /> where the calendar should be. Set the attributes from the table below through script.dataset: data-lang is script.dataset.lang, data-primary is script.dataset.primary. Vue, Svelte and other frameworks work the same way: create the tag in onMounted or its equivalent and remove it on unmount.
The code with your token is ready on the React / Next.js tab in the Booking widget section.
Language and colors are set in the Booking widget section or with attributes right in the code. The attribute wins: this way the widget can look different on different pages of your website.
<script
src="https://widget.uzmitermin.rs/e/YOUR_TOKEN.js"
data-lang="en"
data-primary="#2e7d32"
data-background="transparent"
async
></script>
| Attribute | What it sets | Values |
|---|---|---|
data-lang | Widget language | sr, en, ru. If set neither here nor in the settings - the page language, then the browser language |
data-primary | Main color: buttons, the selected master and services, today's date | A color in #rrggbb format. The button text color - white or dark - is picked automatically |
data-background | Widget background | A #rrggbb color or transparent - then your page background shows through |
data-surface | Background of the calendar header with the date and weekdays | A #rrggbb color |
data-master | Open one master's calendar right away | The master's ID from the Booking widget section |
data-target | The block the widget goes into | A CSS selector, for example #booking |
If an attribute value is invalid, the widget ignores it and uses the setting from the Booking widget section.
The widget tells the page what happens inside it with events on window. For example, this is how you can pass a booking to your analytics:
window.addEventListener('uzmi:booked', (event) => {
gtag('event', 'booking', { appointment_id: event.detail.appointmentId });
});
| Event | When | Data in event.detail |
|---|---|---|
uzmi:ready | The widget has loaded | - |
uzmi:booked | A client has booked | appointmentId |
uzmi:unavailable | The widget cannot accept bookings | code - the reason, see below |
book.salon.rs are allowed only if *.salon.rs is set.code: WIDGET_DISABLED), the subscription has ended (SUBSCRIPTION_INACTIVE) or the widget is not included in your plan (PLAN_NOT_ALLOWED).NOT_FOUND) - for example, after the token was changed. Copy the code from the Booking widget section again.