Skip to content

The tracking snippet

The tracker is one small script, under 2 KB compressed. Add it to the <head> of every page:

<script defer src="https://c.upbeatanalytics.eu/s.js"></script>

That’s all for page views. The site is recognised by the page’s domain, so the snippet is the same for every site. The domain must be the site’s domain or one of its extra domains (site Settings → Other domains).

File Does
s.js Page views, time on page, scroll depth and custom events.
s.auto.js Everything s.js does, plus automatic events for link clicks.

Use one or the other, not both. If a page includes the tracker twice, the second copy does nothing.

All attributes go on the <script> tag.

Attribute Default Does
defer Recommended. Loads the script without holding up the page.
data-auto="outbound downloads contact" all three s.auto.js only. The kinds of clicks to count, separated by spaces: outbound (links to other websites), downloads (file links) and contact (mailto: and tel: links). Without the attribute, s.auto.js counts all three. Unknown words are ignored.
data-respect-dnt="false" respected Also count visitors who send Do Not Track or Global Privacy Control. See below.
data-allow-bots off Also send when the browser is automated (navigator.webdriver), for example in your own end-to-end tests. Leave it out in production.

Example with outbound links and downloads only:

<script defer src="https://c.upbeatanalytics.eu/s.auto.js" data-auto="outbound downloads"></script>

The dashboard builds the right snippet for you: on a site’s dashboard, choose Tracking snippet.

By default the tracker sends nothing when the browser has Do Not Track (navigator.doNotTrack === "1") or Global Privacy Control (navigator.globalPrivacyControl === true) turned on.

To count these visitors too, you need two things:

  1. turn off Respect Do Not Track and Global Privacy Control in the site’s Settings, and
  2. add data-respect-dnt="false" to the snippet on your pages.

The setting alone doesn’t change the snippet that is already on your pages.

For each page view, the tracker sends:

  • a page view when the page loads, with the page’s address, the referrer, the browser’s timezone and language, and the window width;
  • a leave event when the page is hidden or closed, with how long it was visible and how far it was scrolled;
  • your custom events, if any, tied to the page view.

Requests go to https://c.upbeatanalytics.eu/e with navigator.sendBeacon, or fetch with keepalive where that isn’t available. They are plain-text POSTs, so they need no CORS preflight. The collector sets no cookies, so none are sent.

The tracker stores nothing in the browser: no cookies, no localStorage, nothing else. A page view’s id is a random value that lives only while the page is open. Read more in Privacy.

Navigation with the History API counts as a new page view automatically. See Single-page apps.