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.

Before you begin

View demo

Create the widget

  1. Sign in to your company account and open the Booking widget section on this page.

  2. 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.

  3. Save - the code to paste will appear.

Set up the widget

Add the widget to a page

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>

React or Next.js sites

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.

Customize the look

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>
AttributeWhat it setsValues
data-langWidget languagesr, en, ru. If set neither here nor in the settings - the page language, then the browser language
data-primaryMain color: buttons, the selected master and services, today's dateA color in #rrggbb format. The button text color - white or dark - is picked automatically
data-backgroundWidget backgroundA #rrggbb color or transparent - then your page background shows through
data-surfaceBackground of the calendar header with the date and weekdaysA #rrggbb color
data-masterOpen one master's calendar right awayThe master's ID from the Booking widget section
data-targetThe block the widget goes intoA CSS selector, for example #booking

If an attribute value is invalid, the widget ignores it and uses the setting from the Booking widget section.

(Optional) Track bookings

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 });
});
EventWhenData in event.detail
uzmi:readyThe widget has loaded-
uzmi:bookedA client has bookedappointmentId
uzmi:unavailableThe widget cannot accept bookingscode - the reason, see below

If the widget does not appear

What's next