Skip to main content
Enterprise The analytics API is a JavaScript API available on all published projects. It lets your custom scripts listen to visitor interactions like page views, downloads, and more.

Quickstart

In your header or footer scripts, register a listener:
<script>
    standards.on("page_view", function (event) {
        console.log("Page viewed:", event.properties.page_path);
    });
</script>
Or listen to all events at once using *:
<script>
    standards.on("*", function (event) {
        console.log(event.event, event);
    });
</script>

How it works

A window.standards object is initialized in the <head> of every published project, before any custom scripts run. This means your header scripts can call standards.on() immediately — no need to wait for a load or DOMContentLoaded event. Events are emitted by the application after the page renders. All listeners registered by the time the page renders will receive events.

Event shape

Every event has the same structure:
{
  event: 'page_view',          // Event name
  timestamp: 1707840000000,    // Unix timestamp in milliseconds
  properties: {
    page_path: '/brand',       // Current page path
    page_title: 'Brand Guide', // Current page title
    // ...additional properties depending on the event
  },
  user: {
    session_id: 'a1b2c3d4-...',  // Unique session ID (always present)
    email: '[email protected]',   // Only if Include User Identity is enabled
    user_id: 'abc123',           // Only if Include User Identity is enabled
    ip: '192.168.1.1'            // Only if Include User Identity is enabled
  }
}

Events

page_view

Fired on initial page load and when the visitor navigates between pages.
PropertyTypeDescription
page_pathstringThe path of the page viewed
page_titlestringThe title of the page viewed
languagestringThe locale code of the active language (e.g. en, fr, es)

download_file

Fired when a visitor clicks a download link.
PropertyTypeDescription
file_idstringThe file’s unique ID
file_namestringThe file’s display name
file_typestringThe file extension (e.g. pdf, png)

play_video

Fired when a visitor explicitly triggers video playback (click or hover). Not fired when a video autoplays on scroll.
PropertyTypeDescription
video_idstringThe video file’s unique ID
video_titlestringThe video’s alt text or file name

change_slide

Fired when a visitor navigates slides in a Sequence or Toggle element. Not fired on autoplay transitions.
PropertyTypeDescription
slide_idstringThe slide element’s unique ID
slide_titlestringThe slide element’s name
slide_indexnumberThe zero-based index of the new slide

change_language

Fired when a visitor switches the project’s language.
PropertyTypeDescription
languagestringThe locale code selected (e.g. en, fr, es)

copy_hex_code

Fired when a visitor clicks a color swatch to copy its value.
PropertyTypeDescription
hex_codestringThe copied color value
Fired when a visitor clicks a share link button.
PropertyTypeDescription
share_linkstringThe URL or text that was copied to the clipboard

User identity

By default, events include only a session_id — a randomly generated UUID that persists for the browser session. To include the visitor’s email, user_id, and ip in events, enable Include User Identity in the Custom Scripts settings. This only applies to projects that require a sign in to view. Public and password-protected projects do not have user identity data available.

Example

Forwarding to a Third-Party Analytics Platform
<script>
    standards.on("*", function (event) {
        fetch("https://your-analytics-endpoint.com/collect", {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify({
                event: event.event,
                timestamp: event.timestamp,
                session_id: event.user.session_id,
                properties: event.properties,
            }),
        });
    });
</script>

API reference

standards.on(event, callback)

Register a listener for a specific event or all events.
ParameterTypeDescription
eventstringEvent name (e.g. 'page_view') or '*' for all events
callbackfunctionCalled with the event object when the event fires

standards.hasGoogleAnalytics

A boolean indicating whether the native Google Analytics integration is active on this project. Use this to avoid sending duplicate events to GA.