Skip to content
Context
<sessions-context>

An invisible wrapper, and the element you should generally reach for first. Put any combination of Sessions embeds inside a single <sessions-context> and they share one GraphQL client (and its cache), one localization instance, and — when a visitor signs in through one embed — one auth session across all of them. Prefer setting business and auth (and the --sessions-* branding custom properties — see the Branding API) once on the context rather than duplicating them onto each nested embed: the children inherit them, so adding another embed later is a one-liner. Even with a single embed, wrapping it in <sessions-context> is the forward-compatible default.

Install

<script type="module" src="https://assets.sessions.website/embeds/unstable/context.js"></script>
<sessions-context
  business="still-water-yoga-demo"
>
  <sessions-schedule></sessions-schedule>
</sessions-context>

Attributes

Edit any attribute below — the snippet above and the live preview to the side rebuild in place.

business : string

Default business handle shared with every child embed that doesn’t set its own.

auth : token

Embed-scoped JWT shared with every child embed. Updated in place when a visitor signs in through any child.

persist : boolean

When present, persists the signed-in auth token to localStorage (scoped by business handle) so the session survives reloads.

Scripting

Draw your own controls around the element and drive it from your page’s script: read its properties, set its attributes, call its methods and listen for its events.

<sessions-context business="your-business">
  <sessions-schedule></sessions-schedule>
</sessions-context>

<script type="module">
  document.addEventListener('sessions:purchase', (event) => {
    const {purchaseId, value, currency, items} = event;

    // Google Analytics 4
    window.gtag?.('event', 'purchase', {
      transaction_id: purchaseId,
      value,
      currency,
      items: items.map(({name, quantity, price}) => ({
        item_name: name,
        quantity,
        price,
      })),
    });

    // Google Ads conversion (use your own conversion ID and label)
    window.gtag?.('event', 'conversion', {
      send_to: 'AW-XXXXXXXXX/YYYYYYYYYYYY',
      value,
      currency,
      transaction_id: purchaseId,
    });

    // Meta Pixel
    window.fbq?.('track', 'Purchase', {value, currency}, {eventID: purchaseId});

    // TikTok Pixel
    window.ttq?.track('CompletePayment', {
      value,
      currency,
      event_id: purchaseId,
    });
  });
</script>

Events

Each is its own Event subclass, dispatched on the element. Read the state it changed from the element: event.target.selection. What isn’t state, like the booking just made, is on the event itself: event.booking, never event.detail. They bubble and cross shadow roots, so you can listen on the element or any ancestor. Outside a shadow root that holds the element, event.target is that root’s host, so read the element from event.composedPath()[0].

sessions:purchase
SessionsPurchaseEventevent.purchaseId: stringevent.value: numberevent.currency: stringevent.free: booleanevent.items: readonly {name: string; quantity: number; price: number}[]
An order placed through any embed on the page completed — paid, or free (free is true). Fires once per order, even if the visitor reloads the confirmation, and bubbles to document, so one listener covers every embed. Use it to fire your own analytics and ad pixels: value is the order total (tax, tip and donations included) as a decimal in currency, each item’s price is what one unit cost after discounts, and purchaseId is the ID to pass as the transaction or event ID so the platform de-duplicates it. Orders placed on your Sessions page or in the Sessions apps don’t fire it, so your pixel counts will be lower than the Sessions reports. It fires whether or not the visitor consented to your trackers — check your consent manager before you send it on. Campaign tags (utm_*) and ad click IDs (gclid, fbclid, msclkid, ttclid, …) on your page’s URL are recorded with the order automatically, and show in Reports → Where clients come from. To do that, the embeds keep them in the visitor’s browser on your site (localStorage) for up to 90 days — mention it in your privacy notice alongside your other analytics.

Content Security Policy

If your site sets a Content-Security-Policy, allow these origins: the embed loads its files from assets.sessions.website, calls the Sessions API on go.sessions.website, and frames sign-in and maps from embed.sessions.website.

script-src https://assets.sessions.website;
connect-src https://assets.sessions.website https://go.sessions.website;
frame-src https://embed.sessions.website;