---
title: "Snippet and Script Interface"
description: "The snippet of Invantive Waypoint in a web application and its script interface window.waypoint for consent, starts, replays, language and events."
language: en
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/en/docs/invantive-waypoint/interfaces/snippet-and-script-interface
original: https://documentation.invantive.eu/en/docs/invantive-waypoint/interfaces/snippet-and-script-interface
updated: 2026-11-27T00:00:00Z
license: https://documentation.invantive.eu/en/
---

The snippet is the script that shows the experiences of Invantive Waypoint in an application. It consists of a small loader, `https://waypoint.invantive.eu/v1/loader.js`, and a renderer that the loader fetches only when there is something to show. How the loader is placed in a page and how the user id is signed is described in [[Invantive Waypoint/Console/Applications and Installation|Applications and Installation]].

## Behaviour
The snippet behaves as follows:
- It loads with `async`, so the page never waits for it.
- It makes its first call to Waypoint only after the page has loaded and is shown, at a moment the browser is idle. The page is therefore not slower to appear, and an experience appears a fraction of a second after the page.
- Every call to Waypoint is given up after 3 seconds. The page then goes on without Waypoint.
- It sets no cookie, uses no inline script or style attribute, inherits the font of the page and talks to no other host than `waypoint.invantive.eu`.
- It follows the route changes of a single-page application through `history.pushState`, `history.replaceState`, `popstate` and `hashchange`, and asks for the experiences of each new page.
- It shows its content inside a shadow root, so the styles of the page and of Waypoint do not mix.
- It sends events in batches of at most 50, and the remaining events when the page is hidden or closed.
- It shows content as text; the Markdown of a step is turned into elements, never into HTML.

## Script Interface
The loader offers the object `window.waypoint` with the following members:
- `waypoint.consent({ statistics: true })`: passes the consent of the end user for statistics. Without it, page views and events of the application are not sent. `statistics: false` withdraws it, and events of that kind that wait in the queue are dropped.
- `waypoint.start(code)`: starts the experience with that code, as by a click of the end user. Waypoint checks the start again: an experience that the end user is not allowed to see, or that a colleague already completed for the company, is not started. Answers a promise of `true` or `false`.
- `waypoint.replay(code)`: starts the experience again, whatever its state, when it may be replayed.
- `waypoint.setLanguage(code)`: switches the language of the end user, such as `nl`, and fetches the texts again.
- `waypoint.track(event, properties)`: sends an event of the application, such as `waypoint.track('import.completed', { companies: 2 })`. Events tick off items of a checklist, advance a step, start an experience with an event trigger and count towards a goal. They are sent only with consent for statistics.
- `waypoint.version`: the version of the script interface, `1`.

A call made before the loader has arrived can be queued in `window.waypoint.q` as pairs of the name and the arguments:

```html
<script>
  window.waypoint = window.waypoint || { q: [] };
  window.waypoint.q.push(['consent', [{ statistics: true }]]);
</script>
```

## Consent
A page that has a consent banner passes the choice of the end user to the snippet with `waypoint.consent`, at load and whenever the choice changes. Invantive Cloud reads the category for statistics of its consent banner every two seconds and passes it on only when it changes. See [[Invantive Waypoint/Reference/Privacy and Consent|Privacy and Consent]].

## Start by a Link
An address of the application with `?waypoint=<code>` starts that experience again for whoever opens it. The snippet removes the parameter from the address. The console shows the link of an experience under "Link to Start It".

## Editor Mode
The console opens the editor mode with an address that ends in `#waypoint-editor=<token>&experience=<code>`. The snippet then loads a toolbar to pick the elements of the steps. Instead of the experiences of an end user, it shows the draft of the experience being edited at the chosen step, as end users will see it, and registers no events. For an experience that is not anchored on an element, such as a banner, the toolbar offers no picking. A panel edits the texts, buttons, link, theme and dismissibility of the draft, and the placement of a banner; it saves them through the tenant API with the same token. The token is valid for 60 minutes and stays in the session storage of the browser tab. The toolbar reads and saves the steps through the tenant API with this token; the tenant API allows that through CORS only from an origin of the application of the token.

## Release Notes

- [Invantive Cloud](/en/release-notes/products/invantive-cloud)
  - [26.0 to 27.0](/en/release-notes/products/invantive-cloud?step=26.0-to-27.0)
  - [25.0 to 26.0](/en/release-notes/products/invantive-cloud?step=25.0-to-26.0)

