Skip to content

Script and events

The quickest way to start: one script tag, under 1 KB, no cookies. Prefer no client code at all? See server-side collection or a first-party proxy.

Install

Add a site in the dashboard, then put this in the <head> of every page. The install page shows it with your own site id.

index.html
<script defer data-site="YOUR_SITE_ID" src="https://in.nordtally.com/s.js"></script>

Single-page apps are counted automatically on every route change. The install page shows when the first event arrives.

Options

AttributeWhat it does
data-siteYour site id. Required.
data-apiWhere beacons go, for example /stats/e behind a first-party proxy.
data-hashCounts changes of the URL fragment as page views (hash-based routers).
data-dntSends nothing when the browser sends Do Not Track.
data-gpc="ignore"Counts visitors who send Global Privacy Control. By default they are not counted.
data-devAlso counts on localhost, for testing.
data-allow-iframeAlso counts inside iframes.

Custom events

Count sign-ups, purchases or anything else. Add the small queue snippet once, so calls made before the script loads aren't lost, then call nordtally('event', …).

custom events
<script>window.nordtally=window.nordtally||function(){(window.nordtally.q=window.nordtally.q||[]).push(arguments)}</script>

<script>
  nordtally('event', 'Signup', { props: { plan: 'team' } })
  nordtally('event', 'Purchase', { revenue: { amount: '49.50', currency: 'DKK' } })
</script>

Up to 30 properties per event. Values that look like email addresses are dropped; don’t put names, phone numbers or customer ids in properties. Turn an event into a goal in the site settings to see conversion rates.

Consented mode and your cookie banner

In strict and anonymous mode the script never stores anything on the device. Consented mode adds a first-party cookie, but only after a visitor accepts statistics in your consent banner. Without consent they are counted like anonymous mode.

index.html
<script defer data-site="YOUR_SITE_ID" data-mode="consented" src="https://in.nordtally.com/s.js"></script>
<script defer src="https://in.nordtally.com/s.consent.js"></script>

The second script reads your banner’s decision. It works with:

  • Cookie Information (the statistics category)
  • Cookiebot (statistics)
  • Usercentrics: add a service named “Nordtally”, or set data-uc-service or data-uc-category on the consent script
  • Google Consent Mode v2 (analytics_storage)

Using another banner? Call nordtally.consent(true) when the visitor accepts and nordtally.consent(false) when they decline or withdraw. Withdrawing deletes the cookie straight away. Only explicit consent counts: implied or default states never set the cookie.