Dominion

DocsStart

Install the script

One line in your site’s head. Guides for common platforms.

The script

Paste before </head>
<script defer src="https://dominion-8yr.pages.dev/d.min.js" data-site="YOUR-SITE-ID"></script>

Replace YOUR-SITE-ID with your site id, from the install page or the site’s settings. The script loads after your page (defer), sets no cookies and sends one small request per page.

Your platform

Paste it just before </head> on every page, usually in a shared layout or header template.

index.html
<script defer src="https://dominion-8yr.pages.dev/d.min.js" data-site="YOUR-SITE-ID"></script>

Check it works

  1. Open your site in a normal browser window, with no content blocker for it.
  2. Open your dashboard: you should see “1 here now” within a few seconds.
  3. Nothing? Your site’s install page shows the last request it refused and why, for example a domain that isn’t listed in the site’s settings. Adding data-debug to the tag makes the script say why in the browser’s console.

Several domains

Events are accepted from the site’s domain and its subdomains. Add other hostnames (a staging site, a second domain) in the site’s settings. Localhost is never counted.

Options

Add any of these to the script tag:

Script tag options
AttributeWhat it does
data-siteYour site id. Required.
data-hashCount hash routes (/#/settings) as pages.
data-manualDon’t count pageviews by itself; you call dominion('pageview').
data-outboundCount clicks on links to other sites as “Outbound link”.
data-downloadsCount clicks on files (pdf, zip, csv …) as “File download”.
data-localCount visits on localhost too, for testing.
data-debugSay in the console why a visit was or wasn’t counted.
data-apiSend to another address, such as a proxy on your own domain.

Content Security Policy

If your site sends a CSP header, allow the script and its requests:

script-src 'self' https://dominion-8yr.pages.dev;
connect-src 'self' https://dominion-8yr.pages.dev;