Sending stats

POST /api/send

To register an event, you need to send a POST to /api/send with the following data:

Parameters

payload

  • hostname: (string) Name of host.
  • language: (string) Language of visitor (ex. "en-US")
  • referrer: (string) Referrer URL.
  • screen: (string) Screen resolution (ex. "1920x1080")
  • title: (string) Page title.
  • url: (string) Page URL.
  • website: (string) Website ID.
  • name: (string) Name of the event.
  • data: (object)(optional) Additional data for the event.

type: (string) event is currently the only type available.

Sample payload

{
    payload: {
        hostname: "your-hostname",
        language: "en-US",
        referrer: "",
        screen: "1920x1080",
        title: "dashboard",
        url: "/",
        website: "your-website-id",
        name: "event-name",
        data: {
            foo: "bar"
        }
    },
    type: "event"
}

Note, for /api/send requests you do not need to send an authentication token.

Also, you need to send a proper User-Agent HTTP header or your request won't be registered.

Programmatically

You can generate most of these values programmatically with JavaScript using the browser APIs. For example:

{
    payload: {
        hostname: window.location.hostname,
        language: navigator.language,
        referrer: document.referrer,
        screen: `${window.screen.width}x${window.screen.height}`,
        title: document.title,
        url: window.location.pathname,
        website: "your-website-id",
        name: "event-name",
    },
    type: "event"
}