DocsStart
Install the script
One line in your site’s head. Guides for common platforms.
The script
<script defer src="https://dominion.page/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.
<script defer src="https://dominion.page/d.min.js" data-site="YOUR-SITE-ID"></script>App Router: add it to the root layout with next/script. Route changes are counted automatically.
// app/layout.tsx
import Script from 'next/script';
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
{children}
<Script defer src="https://dominion.page/d.min.js" data-site="YOUR-SITE-ID" strategy="afterInteractive" />
</body>
</html>
);
}Pages Router: put the same <Script> in pages/_app.tsx.
- Install a header-scripts plugin, such as WPCode, from Plugins → Add New.
- Open its header section (WPCode: Code Snippets → Header & Footer).
- Paste the script into the header box and save.
Editing header.php also works, but a theme update can undo it.
- Open Site settings → Custom code.
- Paste the script into Head code and save.
- Publish the site. Custom code runs on the published site, not in the Designer.
Webflow needs a paid site plan for custom code.
- Go to Online Store → Themes, then … → Edit code.
- Open
layout/theme.liquid. - Paste the script just before
</head>and save.
<script defer src="https://dominion.page/d.min.js" data-site="YOUR-SITE-ID"></script>Shopify’s checkout pages don’t load your theme. Count purchases with a custom event on the thank-you page, or connect Stripe if you take payments there.
- Open Site settings → General → Custom code.
- Paste the script into “End of <head> tag”.
- Publish.
- Go to Settings → Custom code (under Development & integrations).
- Add custom code, paste the script, choose All pages and Head.
- Apply, then publish.
Wix needs a premium plan and a connected domain for custom code.
- Open Settings → Developer tools → Code injection.
- Paste the script into Header and save.
- In Google Tag Manager, add a tag of type Custom HTML.
- Paste the script, set the trigger to All Pages, and publish the container.
Content blockers that block Tag Manager block the script with it. Pasting it into the page directly counts more visits.
When you can only run JavaScript, load it like this:
Check it works
- Open your site in a normal browser window, with no content blocker for it.
- Open your dashboard: you should see “1 here now” within a few seconds.
- 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-debugto 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:
| Attribute | What it does |
|---|---|
data-site | Your site id. Required. |
data-hash | Count hash routes (/#/settings) as pages. |
data-manual | Don’t count pageviews by itself; you call dominion('pageview'). |
data-outbound | Count clicks on links to other sites as “Outbound link”. |
data-downloads | Count clicks on files (pdf, zip, csv …) as “File download”. |
data-local | Count visits on localhost too, for testing. |
data-debug | Say in the console why a visit was or wasn’t counted. |
data-api | Send 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: