On this page
guide

Quickstart

Add one script tag to your customers' pages. The first event creates the site, so you do not create sites yourself.

1. Get your publishable key

In the dashboard, open API Keys and create a key of the type Publishable. The key starts with pk_, and you can put it in public HTML. See API keys.

2. Add the tracker script

Add the script to each page that your platform serves, for example in your layout template. Give each customer site its own data-site-id. The pages of all customers can be on one domain: Multitrack counts by site ID, not by domain.

<script async
  src="https://multitrack.dev/tracker.js"
  data-site-id="marina-cafe"
  data-publishable-key="pk_3f9a…"></script>

For a React app, use the React component. See the tracker guide.

3. See the first events

The first pageview with a new site ID creates the site in your organisation. You choose the site ID. Use one per domain, per customer or per tenant, as your product needs. The site shows in the dashboard at app.multitrack.dev. Your server can also get it from the sites endpoint with a secret key:

$ curl -s https://api.multitrack.dev/v1/sites \
    -H "X-API-Key: sk_…" | jq '.sites[0]'
{
  "site_id": "marina-cafe",
  "name": null,
  "first_event_at": "2026-05-02T09:14:00Z",
  "last_event_at": "2026-07-06T08:41:12Z",
  "status": "active"
}

4. Show the dashboard to your customer

Add the widget to the page of your product where the customer sees their account, with the same site ID. For React and theming, see the widget guide.

<multitrack-analytics-dashboard
  publishable-key="pk_3f9a…"
  site-id="marina-cafe">
</multitrack-analytics-dashboard>

<script src="https://multitrack.dev/multitrack-widgets.js"></script>
concepts

API keys

Multitrack has two types of key. Create them in the dashboard, on the API Keys page.

Type Use it for Where it can go
Publishable pk_ The tracker and the widget. The key is read-only. It can send events and read analytics. It cannot change or delete data. Public HTML and browser code. You can copy it again from the API Keys page.
Secret sk_ The query API Your server only. The dashboard shows it one time, so store it when you create it.

Each key belongs to your organisation and gives access to all sites in it.

guide

Adding the tracker

The tracker records visits and pageviews. Add it with a script tag, or with the React component.

Add the script

<script async
  src="https://multitrack.dev/tracker.js"
  data-site-id="marina-cafe"
  data-publishable-key="pk_3f9a…"
  data-name="Marina Cafe"></script>
Attribute Description
data-site-id *

Your ID for the site. The first event with a new ID creates the site.

data-publishable-key *

Your publishable key (pk_…).

data-name

Display name of the site, for the dashboard and the API.

* Required. If a required attribute is missing, the tracker does not start.

Start the tracker later

If your page gets the site ID after load, do not set the data attributes. Call multitrack.init() when you know the ID:

<script src="https://multitrack.dev/tracker.js"></script>
<script>
  multitrack.init({
    siteId: 'marina-cafe',
    publishableKey: 'pk_3f9a…',
  });
</script>

Each page has one tracker. A second call to init() with the same site does nothing. A call with another site ends the current visit and starts a visit for the new site. To stop tracking, for example on a page that has no site, call multitrack.stop().

Single-page apps

The tracker records a pageview each time the URL changes, through the browser History API. Routers such as React Router and Vue Router need no extra code.

For a view change that keeps the same URL, for example a tab strip, record the pageview yourself:

window.multitrack.trackPageView();

What the tracker records

  • A visit start, one time per page load.

  • A pageview when the page loads, and each time the URL changes.

  • A visit end when the visitor leaves the page.

  • A conversion when your site calls trackConversion(). See Conversions.

Multitrack does not count bot traffic.

guide

Campaign tags

See which campaign brought each visitor. Add utm_* tags to the links that point to your pages.

https://example.com/?utm_source=newsletter&utm_medium=email&utm_campaign=spring_sale

Multitrack supports utm_* campaign tags.

  • Multitrack reads utm_source, utm_medium, utm_campaign, utm_term and utm_content.

  • A visit counts for a campaign when its first page has utm_source, utm_medium or utm_campaign. Later pages of the visit do not need the tags.

  • Multitrack keeps the case of each value. Newsletter and newsletter are two sources.

  • If a tag occurs more than one time in a URL, Multitrack uses the first value.

guide

Conversions

Count bookings and form submissions, and see which sources bring them. Call trackConversion() when a booking or a form submission completes, for example on the confirmation page.

window.multitrack.trackConversion('booking', { value: 45, currency: 'EUR' });
  • The first argument is the name of the conversion. Use a type, for example booking or signup. Do not use an ID, for example a booking number.

  • The value is optional. If you give value, also give currency, as a three-letter code such as EUR.

  • value must be a number of 0 or more.

  • If the name is empty, or the value or the currency is not correct, the tracker logs a warning and sends nothing.

  • Call init() first. Before init(), the call logs a warning and sends nothing.

Which source gets the conversion

A conversion counts for the session in which it occurs. A session is the events of one visitor with no gap longer than 30 minutes. The conversion gets the source, campaign, entry page, country and device of that session.

For example, a visitor comes from Google at 10:00 and leaves. At 14:00 the same day, the visitor comes back from a bookmark and books. The gap is longer than 30 minutes, so the booking is in a new session, and it counts for "Direct".

Conversion rate

The conversion rate is the number of sessions with at least one conversion, divided by the number of sessions. A session with two bookings counts one time in the rate, and two times in the number of conversions.

Delay

Conversions by source, campaign, entry page, country and device show up to one hour after the call, because Multitrack makes the sessions with a delay. Conversions by page show at once.

guide

Show analytics to your users

The widget puts an analytics dashboard in your own product, so your users can see the traffic of their sites. Your users do not need a Multitrack account. The widget shows metrics, a visitors chart, pages, sources, locations and devices. It uses your publishable key, so you need no server code.

For example:

  • A website builder shows each customer the traffic of their site.

  • A booking or shop platform shows each venue its visitors and sources.

  • An agency puts a live report in its client portal.

Add the script

The script adds the widget elements to the page. It works with any HTML, for example Vue, Rails or PHP templates. Each element has its own shadow DOM, so the CSS of your page does not change the widget.

<script src="https://multitrack.dev/multitrack-widgets.js"></script>

Add the dashboard

<multitrack-analytics-dashboard
  publishable-key="pk_3f9a…"
  site-id="marina-cafe">
</multitrack-analytics-dashboard>
Attribute Description
publishable-key *

Your publishable key (pk_…).

site-id *

The site ID that you set in the tracker.

from

First day of the window. See Date range.

to

Day after the window. See Date range.

locale

Language of the widget text, and format of numbers and dates. Supported: en-US (default), en-GB, de-DE, fr-FR, es-ES, it-IT.

* Required. All elements accept these attributes.

Single elements

To make your own layout, use the elements one by one:

Element Shows Other attributes
<multitrack-analytics-dashboard> Metric cards, visitors chart and all tables conversion-name
<multitrack-visitors-chart> Visitors, sessions and pageviews over time
<multitrack-top-pages-table> Top pages limit
<multitrack-top-sources-table> Top sources, and campaigns in a second tab limit
<multitrack-devices-table> Browsers, operating systems and device types tab (browsers, os, devices)
<multitrack-locations-table> Countries and regions limit, tab (countries, regions)
<multitrack-conversions-by-source-table> Conversions and the conversion rate by source, campaign, entry page, country and device conversion-name, limit, tab (source, campaign, entry_page, country, device)
<multitrack-conversion-value-table> The value of the conversions by source, campaign, country and device, one row per currency conversion-name, limit, tab (source, campaign, country, device)

Loading and errors

<multitrack-analytics-dashboard> sends DOM events, so you can show your own loader or error message:

const dashboard = document.querySelector('multitrack-analytics-dashboard');
dashboard.addEventListener('load', () => showLoader());
dashboard.addEventListener('complete', () => hideLoader());
dashboard.addEventListener('error', (event) => showError(event.detail));
  • load: a request starts.

  • complete: the data arrived. event.detail is the response.

  • error: the request failed. event.detail is the message.

The elements do not accept custom text. To change the widget text, use the React package and its labels prop.

Date range

  • from is the first day of the window.

  • to is the day after the window. The widget does not include it.

  • Both use the format YYYY-MM-DD, in UTC.

  • Without them, the widget shows the last 30 days, including today.

The widget selects the chart interval (hour, day, week or month) from the length of the window.

guide

Theming the widget

The widget gets its colours, font and corner radius from --mt-* CSS custom properties. By default, it uses the font of your page.

Set the properties on the widget or on any parent element. This works for the React components and for the Web Components.

.analytics-panel {
  --mt-color-primary: #4f46e5;
  --mt-radius: 12px;
}
Variable Controls Default
--mt-color-primary First chart line, active tab #3b82f6
--mt-color-secondary Second chart line #10b981
--mt-color-tertiary Third chart line #f59e0b
--mt-color-quaternary Fourth chart line #8b5cf6
--mt-color-text Metric values, labels, row text #111827
--mt-color-muted Captions, axis labels, secondary numbers #6b7280
--mt-color-positive Upward trends #16a34a
--mt-color-negative Downward trends, error messages #dc2626
--mt-color-bar Breakdown row bars #eff6ff
--mt-bg Card backgrounds #ffffff
--mt-border Card, divider and chart grid lines #e5e7eb
--mt-font-family All widget text inherit
--mt-font-size-base Base text size 14px
--mt-radius Corner radius of cards 8px

For dark mode, set different values under your own dark-theme selector. The theme switcher on the homepage uses this method.

guide

Export raw events

Download every event of one site as NDJSON or CSV. Then load the file into a spreadsheet, a data warehouse or a BI tool.

$ curl --fail --show-error --get \
    https://api.multitrack.dev/v1/export/marina-cafe/events \
    -d from_date=2024-01-01 -d to_date=2024-02-01 -d format=csv \
    -H "X-API-Key: sk_…" \
    --output marina-cafe-2024-01.csv
  • Use a secret key (sk_). A publishable key (pk_) gets 403.

  • from_date is the first day. to_date is the day after the last day. Both are UTC.

  • Without dates, the window is the last 30 days, including today. Today is not complete yet, so for complete days send to_date as today.

  • The window is at most 31 days. For a longer period, send one request for each month.

  • format is ndjson (default) or csv.

  • Rows are in event_time order.

Rows

Each row is one event. event_type is vs (visit start), pv (pageview), ve (visit end) or cv (conversion). A visit end has no page or device fields, but it has duration_ms and pageview_count. A conversion has the page fields and conversion_name. If your site sent a value, it also has conversion_value and conversion_currency. An absent value is null in NDJSON and an empty cell in CSV. The API reference lists all columns.

In CSV, a cell that starts with =, +, - or @ gets a ' prefix. This stops spreadsheets from running it as a formula.

Failed exports

The server sends the file while it reads the events. If an error occurs during the download, the server closes the connection before the end of the file. Your HTTP client then reports an error. For example, curl reports transfer closed with outstanding read data remaining and exits with a non-zero code.

Treat a connection error as a failed export. Delete the partial file and request the same window again.

guide

Analytics opt-out

Let visitors stop the tracker on your site. Add an opt-out button with three functions from the tracker.

Add an opt-out button

Put the button on your privacy page, or on any page of the site. It shows if this browser is included in the analytics, and changes it.

<p id="analytics-status"></p>
<button id="analytics-button" type="button" hidden></button>

<script>
  const status = document.getElementById('analytics-status');
  const button = document.getElementById('analytics-button');

  function render() {
    const reason = window.multitrack?.isOptedOut();
    button.hidden = reason === undefined || reason === 'browser';
    if (reason === undefined) {
      status.textContent = 'Analytics is blocked in this browser.';
    } else if (reason === 'browser') {
      status.textContent = 'Your browser asks not to be tracked, so it is left out of our analytics.';
    } else if (reason === 'user') {
      status.textContent = 'This browser is excluded from our analytics.';
      button.textContent = 'Include this browser again';
    } else {
      status.textContent = 'This browser is included in our analytics.';
      button.textContent = 'Exclude this browser';
    }
  }

  button.addEventListener('click', () => {
    if (window.multitrack.isOptedOut() === 'user') {
      window.multitrack.optIn();
    } else {
      window.multitrack.optOut();
    }
    render();
  });
  window.addEventListener('load', render);
</script>

The example waits for the load event, because the tracker script is async. If a content blocker stops the script, window.multitrack is missing, and the example says so.

Opt-out functions

  • isOptedOut() returns false when the browser is included, 'user' after optOut(), and 'browser' when Global Privacy Control or Do Not Track is on.

  • optOut() stops the tracker on this site, on this page and on later visits.

  • optIn() undoes optOut(). It has no effect when isOptedOut() returns 'browser'.

With the script tag, call them on window.multitrack. With the npm package, import them from @multitrack-dev/tracker.

The opt-out is stored in the browser's localStorage, under the key multitrack_ignore. It is not a cookie. It applies only to the site where the visitor opts out: an opt-out on shop.example.com does not apply to blog.example.com. If the browser blocks storage, optOut() cannot keep the choice.

Browser settings

The tracker sends no events when the browser has Global Privacy Control or Do Not Track turned on. This applies on every site that uses Multitrack, with no work for you. globalprivacycontrol.org lists the browsers and extensions that send Global Privacy Control.

How the visitor ID works

The tracker stores nothing in the browser to identify a visitor. The Multitrack server makes the visitor ID from:

  • a random value that changes every day (UTC)

  • your organisation and the site ID

  • the IP address of the visitor

  • the user agent of the browser.

The server keeps only a SHA-256 hash of these values. It does not store the IP address or the user agent. The same visitor gets a new ID the next day, and different sites see different IDs.

A visitor who changes network, for example from Wi-Fi to mobile data, gets a new ID. Visitors who share one IP address and the same browser get the same ID.

guide

Keep the original source

Show the site that sent the visitor, also when your page opens from your customer's site.

The problem

Your page can open in a frame on your customer's site, or from a link on it. Then your page loses the source of the visit:

  • The referrer: it is your customer's site, not the site that sent the visitor.

  • The campaign tags utm_source, utm_medium, utm_campaign, utm_term and utm_content: they stay on the URL of your customer's page.

Google ──► school.example/              your customer's site
              └─ frame: booking.example.com/school   the tracker runs here

Top source of the visit: school.example. Google is lost.

A frame cannot read the page around it, so the tracker in the frame cannot see the original source.

The solution

This needs a script of yours on your customer's site, for example the script that embeds your booking widget. Your customer adds it to their site.

The script reads the original source. It adds the source to the URL of your page. The tracker on your page reads it and records the original source:

Google ──► school.example/
              └─ frame: booking.example.com/school?mt_ref=https://www.google.com/

Top source of the visit: Google.

When to use it

  • Your script creates a frame on your customer's site, for example a booking or form widget: add sourceParams() to the frame URL.

  • Your script is on your customer's pages, and those pages link to your site: call carrySource().

Limits

  • A page of your customer's site where your script does not run keeps your customer's site as the source. For example, a plain link or a plain <iframe> that the customer adds by hand.

  • "Open link in new tab" from the right-click menu does not add the source to the link.

  • Keep the parameters on the URL of your page until the tracker starts. A redirect that drops the query string loses them.

Add it to your embed script

Put this code in the script that you give to your customers. It needs no other script on their pages.

import { carrySource, sourceParams } from '@multitrack-dev/tracker';

carrySource({ hosts: ['booking.example.com'] });

function embedBooking(iframe: HTMLIFrameElement, bookingUrl: string): void {
  const url = new URL(bookingUrl);
  for (const [name, value] of sourceParams()) {
    url.searchParams.append(name, value);
  }
  iframe.src = url.href;
}

Source functions

  • carrySource({ hosts }) keeps the source of the visit while the visitor moves between your customer's pages. Call it on each page load. When the visitor clicks a link to one of hosts, it adds the source to the link. Give the host with its port when the port is not the default, for example localhost:3000.

  • sourceParams() returns a URLSearchParams with mt_ref (the original referrer) and the utm_* tags. Add them to the URL of a frame when you create it.

carrySource() stores the source in the browser's sessionStorage, under the key multitrack_source. The browser deletes it when the tab closes. carrySource() does nothing when the visitor opted out of the analytics.

api reference · v1

Query API

REST API to list your sites and read their analytics.

Reporting window

Analytics endpoints take from_date and to_date as UTC calendar dates (YYYY-MM-DD).

  • The window starts at 00:00 UTC on from_date.

  • The window ends at 00:00 UTC on to_date. The day of to_date is not included.

Example: from_date=2024-01-01&to_date=2024-02-01 returns all of January 2024.

Both dates are optional. Without them, the window is the last 30 days, including today.

Definitions

  • Visitor. One browser, identified by the tracker.

  • Visit. Starts each time a page loads the tracker script.

  • Session. Events from one visitor with no gap longer than 30 minutes.

  • Conversion. A call to trackConversion() on your site, for example when a booking completes.

Session metrics can lag behind pageviews by up to one hour. These metrics are sessions, bounce rate, average duration, entry pages, exit pages, and conversions by source, campaign, entry page, country and device.

Errors

Errors return a JSON body with a message field. Unknown query parameters return 400.

Authentication

Send a secret key in the X-API-Key header. Call the API from your server only. In the browser, use the widget with a publishable key. See API keys.

$ curl https://api.multitrack.dev/v1/sites \
    -H "X-API-Key: sk_…"
GET /v1/sites List sites

Returns the sites in your organisation, one page at a time. The list includes sites with status deleting.

query parameters
Name Type Description
page integer (≥ 1) = 1

Page number. The first page is 1.

page_size integer (1–100) = 25

Number of sites on each page.

search_term string

Returns only sites whose site_id or name contains this text. The match is not case-sensitive.

Example: blog

sort_by name | last_event_at

Sort order.

  • name: alphabetical by name.

  • last_event_at: most recent activity first. Sites with no events come last.

response · 200
{
  "sites": [
    {
      "site_id": "acme-blog-prod",
      "name": "Acme Blog",
      "first_event_at": "2026-06-10T11:22:33Z",
      "last_event_at": "2026-06-26T15:03:44Z",
      "status": "active"
    },
    {
      "site_id": "acme-shop-staging",
      "name": null,
      "first_event_at": null,
      "last_event_at": null,
      "status": "active"
    }
  ],
  "pagination": {
    "page": 1,
    "page_size": 25,
    "total": 2
  }
}
DELETE /v1/sites/{site_id} Delete a site

Deletes the site and all of its analytics data. You cannot undo this.

  • The site status changes to deleting immediately.

  • The data is removed in the background.

  • When removal is complete, the site no longer exists and its endpoints return 404.

A repeated request for a site that is already deleting returns 204.

path parameters
Name Type Description
site_id * string

Site identifier. This is the siteId that you set in the tracker.

Example: acme-blog-prod

response · 204
GET /v1/analytics/{site_id}/overview Overview time series

Returns one point per time bucket in the reporting window. Each point has unique visitors, pageviews, sessions, bounce rate, average session duration and conversions.

The response omits buckets with no data. Fill the gaps on the client if you need a continuous series.

path parameters
Name Type Description
site_id * string

Site identifier. This is the siteId that you set in the tracker.

Example: acme-blog-prod

query parameters
Name Type Description
from_date string

First day of the reporting window (UTC, inclusive). Default: 30 days before to_date.

Example: 2024-01-01

to_date string

Day after the last day of the reporting window (UTC, exclusive). Must be on or after from_date. If the two dates are equal, the window is empty. Default: tomorrow, so the window includes today.

Example: 2024-02-01

interval hour | day | week | month

Size of each time bucket. All buckets use UTC.

  • hour: one hour.

  • day: one calendar day.

  • week: one calendar week, starting on Monday.

  • month: one calendar month.

Default, from the number of days between from_date and to_date:

  • 2 or less: hour.

  • 3 to 90: day.

  • 91 to 366: week.

  • More than 366: month.

hour is allowed only for windows of 31 days or less. A longer window returns 400.

response · 200
{
  "series": [
    {
      "bucket": "2024-01-15T00:00:00.000Z",
      "unique_visitors": 1284,
      "sessions": 942,
      "pageviews": 3102,
      "bounce_rate": 0.37,
      "avg_duration_ms": 185000,
      "converted_sessions": 38,
      "conversions": 41
    }
  ]
}
GET /v1/analytics/{site_id}/pages Top pages

Returns URL paths ranked by pageviews. count is the number of pageviews.

path parameters
Name Type Description
site_id * string

Site identifier. This is the siteId that you set in the tracker.

Example: acme-blog-prod

query parameters
Name Type Description
from_date string

First day of the reporting window (UTC, inclusive). Default: 30 days before to_date.

Example: 2024-01-01

to_date string

Day after the last day of the reporting window (UTC, exclusive). Must be on or after from_date. If the two dates are equal, the window is empty. Default: tomorrow, so the window includes today.

Example: 2024-02-01

limit integer (1–100) = 10

Maximum number of rows in each ranked list.

response · 200
{
  "items": [
    {
      "name": "/home",
      "count": 900
    },
    {
      "name": "/docs",
      "count": 120
    }
  ]
}
GET /v1/analytics/{site_id}/entry-pages Top entry pages

Returns URL paths ranked by the number of sessions that started on them. count is the number of sessions.

path parameters
Name Type Description
site_id * string

Site identifier. This is the siteId that you set in the tracker.

Example: acme-blog-prod

query parameters
Name Type Description
from_date string

First day of the reporting window (UTC, inclusive). Default: 30 days before to_date.

Example: 2024-01-01

to_date string

Day after the last day of the reporting window (UTC, exclusive). Must be on or after from_date. If the two dates are equal, the window is empty. Default: tomorrow, so the window includes today.

Example: 2024-02-01

limit integer (1–100) = 10

Maximum number of rows in each ranked list.

response · 200
{
  "items": [
    {
      "name": "/home",
      "count": 900
    },
    {
      "name": "/docs",
      "count": 120
    }
  ]
}
GET /v1/analytics/{site_id}/exit-pages Top exit pages

Returns URL paths ranked by the number of sessions that ended on them. count is the number of sessions.

path parameters
Name Type Description
site_id * string

Site identifier. This is the siteId that you set in the tracker.

Example: acme-blog-prod

query parameters
Name Type Description
from_date string

First day of the reporting window (UTC, inclusive). Default: 30 days before to_date.

Example: 2024-01-01

to_date string

Day after the last day of the reporting window (UTC, exclusive). Must be on or after from_date. If the two dates are equal, the window is empty. Default: tomorrow, so the window includes today.

Example: 2024-02-01

limit integer (1–100) = 10

Maximum number of rows in each ranked list.

response · 200
{
  "items": [
    {
      "name": "/home",
      "count": 900
    },
    {
      "name": "/docs",
      "count": 120
    }
  ]
}
GET /v1/analytics/{site_id}/sources Top traffic sources

Returns traffic sources ranked by visits. Each row is one pair of source and medium.

path parameters
Name Type Description
site_id * string

Site identifier. This is the siteId that you set in the tracker.

Example: acme-blog-prod

query parameters
Name Type Description
from_date string

First day of the reporting window (UTC, inclusive). Default: 30 days before to_date.

Example: 2024-01-01

to_date string

Day after the last day of the reporting window (UTC, exclusive). Must be on or after from_date. If the two dates are equal, the window is empty. Default: tomorrow, so the window includes today.

Example: 2024-02-01

limit integer (1–100) = 10

Maximum number of rows in each ranked list.

response · 200
{
  "items": [
    {
      "source": "google.com",
      "medium": "organic",
      "events": 512
    },
    {
      "source": "direct",
      "medium": "direct",
      "events": 88
    }
  ]
}
GET /v1/analytics/{site_id}/campaigns Top campaigns

Returns visits with campaign tags, ranked by visits. Each row is one combination of utm_source, utm_medium and utm_campaign from the page URL of the first page of the visit. A visit without any of these three tags is not in the list.

path parameters
Name Type Description
site_id * string

Site identifier. This is the siteId that you set in the tracker.

Example: acme-blog-prod

query parameters
Name Type Description
from_date string

First day of the reporting window (UTC, inclusive). Default: 30 days before to_date.

Example: 2024-01-01

to_date string

Day after the last day of the reporting window (UTC, exclusive). Must be on or after from_date. If the two dates are equal, the window is empty. Default: tomorrow, so the window includes today.

Example: 2024-02-01

limit integer (1–100) = 10

Maximum number of rows in each ranked list.

response · 200
{
  "items": [
    {
      "source": "newsletter",
      "medium": "email",
      "campaign": "spring_sale",
      "events": 120
    },
    {
      "source": "google",
      "medium": "cpc",
      "campaign": "brand",
      "events": 45
    }
  ]
}
GET /v1/analytics/{site_id}/devices Browsers, operating systems and device types

Returns three lists ranked by visits. count is the number of visits. Each list has a fixed maximum length:

  • browsers: 20

  • os: 10

  • devices: 5

path parameters
Name Type Description
site_id * string

Site identifier. This is the siteId that you set in the tracker.

Example: acme-blog-prod

query parameters
Name Type Description
from_date string

First day of the reporting window (UTC, inclusive). Default: 30 days before to_date.

Example: 2024-01-01

to_date string

Day after the last day of the reporting window (UTC, exclusive). Must be on or after from_date. If the two dates are equal, the window is empty. Default: tomorrow, so the window includes today.

Example: 2024-02-01

response · 200
{
  "browsers": [
    {
      "name": "Chrome",
      "count": 800
    }
  ],
  "os": [
    {
      "name": "Windows",
      "count": 500
    }
  ],
  "devices": [
    {
      "name": "desktop",
      "count": 700
    }
  ]
}
GET /v1/analytics/{site_id}/locations Top countries and regions

Returns countries and regions ranked by visits. limit applies to each list separately.

path parameters
Name Type Description
site_id * string

Site identifier. This is the siteId that you set in the tracker.

Example: acme-blog-prod

query parameters
Name Type Description
from_date string

First day of the reporting window (UTC, inclusive). Default: 30 days before to_date.

Example: 2024-01-01

to_date string

Day after the last day of the reporting window (UTC, exclusive). Must be on or after from_date. If the two dates are equal, the window is empty. Default: tomorrow, so the window includes today.

Example: 2024-02-01

limit integer (1–100) = 10

Maximum number of rows in each ranked list.

response · 200
{
  "countries": {
    "US": 400,
    "DE": 120
  },
  "regions": [
    {
      "region": "CA",
      "count": 90
    },
    {
      "region": "TX",
      "count": 70
    }
  ]
}
GET /v1/analytics/{site_id}/conversions Conversions by dimension

Returns conversions and the conversion rate for one dimension, set by by.

A conversion counts for the session in which it occurs. Example: a visitor comes from Google at 10:00 and leaves. At 14:00 the same day, the visitor comes back from a bookmark and books. The gap is longer than 30 minutes, so the booking is in a new session, and it counts for direct.

The rate is the number of sessions with at least one conversion, divided by the number of sessions. A session with two conversions counts once in the rate, and twice in conversions.

Rows with sessions but no conversions are in the list, with a rate of 0.

path parameters
Name Type Description
site_id * string

Site identifier. This is the siteId that you set in the tracker.

Example: acme-blog-prod

query parameters
Name Type Description
from_date string

First day of the reporting window (UTC, inclusive). Default: 30 days before to_date.

Example: 2024-01-01

to_date string

Day after the last day of the reporting window (UTC, exclusive). Must be on or after from_date. If the two dates are equal, the window is empty. Default: tomorrow, so the window includes today.

Example: 2024-02-01

by * source | campaign | entry_page | page | country | device

The dimension of each row:

  • source: the referrer of the session, or direct.

  • campaign: the utm_campaign of the session. Sessions with no campaign are not in the list.

  • entry_page: the first page of the session.

  • page: the page where the conversion occurred. These rows have no rate.

  • country: the country of the session.

  • device: the device type of the session.

name string

Count only the conversions with this name. Without it, all names count.

Example: booking

limit integer (1–100) = 10

Maximum number of rows in each ranked list.

response · 200
{
  "items": [
    {
      "key": "google.com",
      "sessions": 200,
      "converted_sessions": 10,
      "conversion_rate": 0.05,
      "conversions": 12,
      "values": [
        {
          "currency": "EUR",
          "amount": 540
        }
      ]
    },
    {
      "key": "direct",
      "sessions": 100,
      "converted_sessions": 2,
      "conversion_rate": 0.02,
      "conversions": 2,
      "values": []
    }
  ]
}
GET /v1/analytics/{site_id}/conversion-values Conversion value by dimension

Returns the value of the conversions for one dimension, set by by. Each row is one value of the dimension in one currency. Values in different currencies are not added together.

  • Rows are grouped by currency. The currency with the most conversions comes first.

  • In each currency, rows are in descending order of amount. limit applies to each currency.

  • Conversions with no value are not counted.

A conversion counts for the session in which it occurs, the same as in /conversions.

path parameters
Name Type Description
site_id * string

Site identifier. This is the siteId that you set in the tracker.

Example: acme-blog-prod

query parameters
Name Type Description
from_date string

First day of the reporting window (UTC, inclusive). Default: 30 days before to_date.

Example: 2024-01-01

to_date string

Day after the last day of the reporting window (UTC, exclusive). Must be on or after from_date. If the two dates are equal, the window is empty. Default: tomorrow, so the window includes today.

Example: 2024-02-01

by * source | campaign | entry_page | country | device

The dimension of each row: source, campaign, entry_page, country or device. These are the same as in /conversions. page is not available.

name string

Count only the conversions with this name. Without it, all names count.

Example: booking

limit integer (1–100) = 10

Maximum number of rows in each ranked list.

response · 200
{
  "items": [
    {
      "key": "google.com",
      "currency": "GBP",
      "amount": 4320,
      "conversions": 41
    },
    {
      "key": "direct",
      "currency": "GBP",
      "amount": 1180,
      "conversions": 12
    },
    {
      "key": "google.com",
      "currency": "EUR",
      "amount": 300,
      "conversions": 6
    }
  ]
}
GET /v1/analytics/{site_id}/conversion-names Conversion names

Returns the conversion names in the reporting window, with the number of conversions of each. Use it to find the names that a site sends.

path parameters
Name Type Description
site_id * string

Site identifier. This is the siteId that you set in the tracker.

Example: acme-blog-prod

query parameters
Name Type Description
from_date string

First day of the reporting window (UTC, inclusive). Default: 30 days before to_date.

Example: 2024-01-01

to_date string

Day after the last day of the reporting window (UTC, exclusive). Must be on or after from_date. If the two dates are equal, the window is empty. Default: tomorrow, so the window includes today.

Example: 2024-02-01

response · 200
{
  "items": [
    {
      "name": "booking",
      "count": 12
    },
    {
      "name": "signup",
      "count": 3
    }
  ]
}
GET /v1/analytics/{site_id}/bundle All metrics in one request

Returns the responses of these endpoints in one body:

  • /overview

  • /pages

  • /sources

  • /campaigns

  • /devices

  • /locations

  • /conversions, for each value of by

  • /conversion-values, for each value of by

  • /conversion-names

limit applies to pages, sources, campaigns, locations, conversions and conversion_values. name applies only to conversions and conversion_values.

To compare with an earlier period, send prior_from_date and prior_to_date. The response then has a second overview series in prior_overview, with the same interval.

path parameters
Name Type Description
site_id * string

Site identifier. This is the siteId that you set in the tracker.

Example: acme-blog-prod

query parameters
Name Type Description
from_date string

First day of the reporting window (UTC, inclusive). Default: 30 days before to_date.

Example: 2024-01-01

to_date string

Day after the last day of the reporting window (UTC, exclusive). Must be on or after from_date. If the two dates are equal, the window is empty. Default: tomorrow, so the window includes today.

Example: 2024-02-01

interval hour | day | week | month

Size of each time bucket. All buckets use UTC.

  • hour: one hour.

  • day: one calendar day.

  • week: one calendar week, starting on Monday.

  • month: one calendar month.

Default, from the number of days between from_date and to_date:

  • 2 or less: hour.

  • 3 to 90: day.

  • 91 to 366: week.

  • More than 366: month.

hour is allowed only for windows of 31 days or less. A longer window returns 400.

limit integer (1–100) = 10

Maximum number of rows in each ranked list.

prior_from_date string

First day of the comparison window (UTC, inclusive). Send it together with prior_to_date.

Example: 2023-12-01

prior_to_date string

Day after the last day of the comparison window (UTC, exclusive). Send it together with prior_from_date.

Example: 2024-01-01

name string

Count only the conversions with this name. Without it, all names count.

Example: booking

response · 200
{
  "overview": {
    "series": [
      {
        "bucket": "2024-01-15T00:00:00.000Z",
        "unique_visitors": 1284,
        "sessions": 942,
        "pageviews": 3102,
        "bounce_rate": 0.37,
        "avg_duration_ms": 185000,
        "converted_sessions": 38,
        "conversions": 41
      }
    ]
  },
  "prior_overview": {
    "series": [
      {
        "bucket": "2023-12-15T00:00:00.000Z",
        "unique_visitors": 1102,
        "sessions": 815,
        "pageviews": 2760,
        "bounce_rate": 0.41,
        "avg_duration_ms": 172000,
        "converted_sessions": 30,
        "conversions": 33
      }
    ]
  },
  "pages": {
    "items": [
      {
        "name": "/home",
        "count": 900
      },
      {
        "name": "/docs",
        "count": 120
      }
    ]
  },
  "sources": {
    "items": [
      {
        "source": "google.com",
        "medium": "organic",
        "events": 512
      },
      {
        "source": "direct",
        "medium": "direct",
        "events": 88
      }
    ]
  },
  "campaigns": {
    "items": [
      {
        "source": "newsletter",
        "medium": "email",
        "campaign": "spring_sale",
        "events": 120
      }
    ]
  },
  "devices": {
    "browsers": [
      {
        "name": "Chrome",
        "count": 800
      }
    ],
    "os": [
      {
        "name": "Windows",
        "count": 500
      }
    ],
    "devices": [
      {
        "name": "desktop",
        "count": 700
      }
    ]
  },
  "locations": {
    "countries": {
      "US": 400,
      "DE": 120
    },
    "regions": [
      {
        "region": "CA",
        "count": 90
      }
    ]
  },
  "conversions": {
    "source": [
      {
        "key": "google.com",
        "sessions": 200,
        "converted_sessions": 10,
        "conversion_rate": 0.05,
        "conversions": 12,
        "values": [
          {
            "currency": "EUR",
            "amount": 540
          }
        ]
      }
    ],
    "campaign": [],
    "entry_page": [],
    "page": [
      {
        "key": "/booking/done",
        "sessions": null,
        "converted_sessions": null,
        "conversion_rate": null,
        "conversions": 12,
        "values": [
          {
            "currency": "EUR",
            "amount": 540
          }
        ]
      }
    ],
    "country": [],
    "device": []
  },
  "conversion_values": {
    "source": [
      {
        "key": "google.com",
        "currency": "EUR",
        "amount": 540,
        "conversions": 12
      }
    ],
    "campaign": [],
    "entry_page": [],
    "country": [],
    "device": []
  },
  "conversion_names": {
    "items": [
      {
        "name": "booking",
        "count": 12
      }
    ]
  }
}
GET /v1/export/{site_id}/events Export raw events

Returns every event of the site in the window, one row per event, ordered by event_time. The window is at most 31 days. To export a longer period, send one request for each month. Without dates, the window is the last 30 days, including today.

  • ndjson: one JSON object per line. Absent values are null.

  • csv: a header row, then one row per event. Absent values are empty cells. A cell that starts with =, +, - or @ gets a ' prefix, so spreadsheets do not run it as a formula.

The response streams. It has no Content-Length. If an error occurs after the first row, the server closes the connection before the end of the body. Your HTTP client then reports an error. Treat this as a failed export and request the same window again.

Events older than the data retention period of your organisation are deleted, so the export does not include them.

url and referrer contain the full URL, query string included. They can contain personal data that your site puts in its URLs.

path parameters
Name Type Description
site_id * string

Site identifier. This is the siteId that you set in the tracker.

Example: acme-blog-prod

query parameters
Name Type Description
from_date string

First day of the export window (UTC, inclusive). Default: 30 days before to_date.

Example: 2024-01-01

to_date string

Day after the last day of the export window (UTC, exclusive). Must be on or after from_date, and at most 31 days after it. Default: tomorrow, so the window includes today. Today is not complete yet. For complete days only, send today's date.

Example: 2024-02-01

format ndjson | csv

File format.

  • ndjson: newline-delimited JSON, one object per line.

  • csv: comma-separated values with a header row (RFC 4180).

Default: ndjson.

response · 200