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.
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:
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();
Install the package
$ npm install @multitrack-dev/tracker
The component needs React 18 or later. init and the other
functions work without React.
Add the component
Render the component one time, high in the tree, for example next to the
router. It renders nothing.
Your ID for the site. The first event with a new ID creates the site.
publishableKey*
Your publishable key (pk_…).
name
Display name of the site, for the dashboard and the API.
* Required. If a required prop is
empty, the tracker does not start.
Route changes
The tracker records a pageview each time the URL changes, through the browser
History API. React Router, Next.js and other routers need no extra code.
For a view change that keeps the same URL, for example a tab strip, record the
pageview yourself:
import { trackPageView } from '@multitrack-dev/tracker';
trackPageView();
Server rendering
The component starts the tracker in an effect, and the package has the 'use client' directive. A Next.js server component can render it.
Each page has one tracker. A remount with the same props does nothing, so React
StrictMode does not start a second tracker. If siteId changes, the
tracker ends the current visit and starts a visit for the new site. When the
component unmounts, tracking stops. Render it only on the pages to track.
Without the component, call init() and stop() from the
package. stop() ends the current visit. The tracker sends nothing
more until the next init().
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.
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.
AnalyticsDashboard and the two conversion tables only. Counts only the conversions with this name. In AnalyticsDashboard, it changes the two conversion tables, not the "Conversion rate" card.
* Required. All components accept these
props, except where the description says otherwise.
Single components
To make your own layout, use the components one by one:
Component
Shows
Other props
AnalyticsDashboard
Metric cards, visitors chart and all tables
showTrends, conversionName
VisitorsChart
Visitors, sessions and pageviews over time
metrics, height
TopPagesTable
Top pages, entry pages or exit pages
limit, tab (pages, entry-pages, exit-pages)
TopSourcesTable
Top sources, and campaigns in a second tab
limit
DevicesTable
Browsers, operating systems and device types
tab (browsers, os, devices)
LocationsTable
Countries and regions
limit, tab (countries, regions)
ConversionsBySourceTable
Conversions and the conversion rate by source, campaign, entry page, country and device
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.
import { isOptedOut, optIn, optOut } from '@multitrack-dev/tracker';
import { useEffect, useState } from 'react';
export function AnalyticsOptOut() {
const [reason, setReason] = useState<ReturnType<typeof isOptedOut> | null>(null);
useEffect(() => setReason(isOptedOut()), []);
if (reason === null) {
return null;
}
if (reason === 'browser') {
return <p>Your browser asks not to be tracked, so it is left out of our analytics.</p>;
}
function toggle() {
if (reason === 'user') {
optIn();
} else {
optOut();
}
setReason(isOptedOut());
}
return (
<>
<p>
{reason === 'user'
? 'This browser is excluded from our analytics.'
: 'This browser is included in our analytics.'}
</p>
<button type="button" onClick={toggle}>
{reason === 'user' ? 'Include this browser again' : 'Exclude this browser'}
</button>
</>
);
}
The functions work without MultitrackAnalytics on the page.
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;
}
// The block to copy, below. It defines carrySource() and sourceParams().
carrySource({ hosts: ['booking.example.com'] });
function embedBooking(iframe, bookingUrl) {
const url = new URL(bookingUrl);
for (const [name, value] of sourceParams()) {
url.searchParams.append(name, value);
}
iframe.src = url.href;
}
Put this block at the top of your embed script. It is the same code as the
npm package. Copy it again when you update to a new version of the tracker.
const OPT_OUT_KEY = "multitrack_ignore";
function getOptOutReason(dom) {
if (dom.navigator.globalPrivacyControl || dom.navigator.doNotTrack === "1") {
return "browser";
}
if (dom.storage.getItem(OPT_OUT_KEY) === "true") {
return "user";
}
return false;
}
const SOURCE_KEY = "multitrack_source";
const SOURCE_REFERRER_PARAM = "mt_ref";
const CAMPAIGN_TAGS = [
"utm_source",
"utm_medium",
"utm_campaign",
"utm_term",
"utm_content"
];
function isExternalReferrer(referrer) {
try {
return new URL(referrer).host !== window.location.host;
} catch {
return true;
}
}
function currentPageSource() {
const params = new URLSearchParams();
const referrer = document.referrer;
if (isExternalReferrer(referrer)) {
params.set(SOURCE_REFERRER_PARAM, referrer);
}
const pageParams = new URLSearchParams(window.location.search);
for (const tag of CAMPAIGN_TAGS) {
const value = pageParams.get(tag);
if (value !== null) {
params.set(tag, value);
}
}
return params;
}
function readSaved() {
try {
return window.sessionStorage.getItem(SOURCE_KEY);
} catch {
return null;
}
}
function save(value) {
try {
window.sessionStorage.setItem(SOURCE_KEY, value);
} catch {
}
}
function isOptedOut() {
const reason = getOptOutReason({
navigator: {
webdriver: window.navigator.webdriver,
globalPrivacyControl: window.navigator.globalPrivacyControl === true,
doNotTrack: window.navigator.doNotTrack
},
storage: {
getItem(key) {
try {
return window.localStorage.getItem(key);
} catch {
return null;
}
}
}
});
return reason !== false;
}
function sourceParams() {
const saved = readSaved();
return saved === null ? currentPageSource() : new URLSearchParams(saved);
}
let linkListenerAdded = false;
function addSourceToLink(target, hosts) {
const link = target instanceof Element ? target.closest("a[href]") : null;
if (!(link instanceof HTMLAnchorElement)) {
return;
}
let url;
try {
url = new URL(link.href);
} catch {
return;
}
if (!hosts.includes(url.host) || url.searchParams.has(SOURCE_REFERRER_PARAM)) {
return;
}
for (const [name, value] of sourceParams()) {
url.searchParams.append(name, value);
}
link.href = url.href;
}
function carrySource(options) {
if (isOptedOut()) {
return;
}
const pageParams = new URLSearchParams(window.location.search);
const hasCampaignTags = CAMPAIGN_TAGS.some((tag) => pageParams.has(tag));
if (hasCampaignTags || isExternalReferrer(document.referrer)) {
save(currentPageSource().toString());
}
if (!linkListenerAdded) {
linkListenerAdded = true;
document.addEventListener("click", (event) => {
addSourceToLink(event.target, options.hosts);
});
}
}
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.
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}/overviewOverview 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.
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.
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.
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.
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.
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.
GET/v1/analytics/{site_id}/devicesBrowsers, 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.
GET/v1/analytics/{site_id}/locationsTop 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.
GET/v1/analytics/{site_id}/conversionsConversions 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.
GET/v1/analytics/{site_id}/conversion-valuesConversion 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.
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.
GET/v1/analytics/{site_id}/bundleAll 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.
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).