Install the snippet

One script tag per site. Replace YOUR-WEBSITE-ID with the ID shown for your site in the app; the app also shows the full snippet ready to copy.

Plain HTML

Paste the snippet inside <head> on every page, or once in your shared layout or template.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>My site</title>
    <script defer src="https://t.usehonestcount.com/script.js" data-website-id="YOUR-WEBSITE-ID"></script>
  </head>
  <body>…</body>
</html>

This also works for static site generators (Hugo, Jekyll, Eleventy, Astro): add it to the base layout.

Next.js

App Router

Add the script to your root layout with next/script. Page changes made by the client-side router are counted automatically, because the tracker listens for history changes.

// app/layout.tsx
import Script from 'next/script';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        {children}
        <Script
          src="https://t.usehonestcount.com/script.js"
          data-website-id="YOUR-WEBSITE-ID"
          strategy="afterInteractive"
        />
      </body>
    </html>
  );
}

Pages Router

// pages/_app.tsx
import type { AppProps } from 'next/app';
import Script from 'next/script';

export default function App({ Component, pageProps }: AppProps) {
  return (
    <>
      <Script src="https://t.usehonestcount.com/script.js" data-website-id="YOUR-WEBSITE-ID" strategy="afterInteractive" />
      <Component {...pageProps} />
    </>
  );
}

Tip: keep the ID in an environment variable such as NEXT_PUBLIC_HC_WEBSITE_ID and render the script only in production, so local development does not use up your events.

WordPress

Option A: a header-code plugin (no code)

  1. Install a plugin that adds code to your site header, such as WPCode (formerly Insert Headers and Footers).
  2. Open its Header section, paste the snippet and save.
  3. If you use a caching plugin, clear its cache, then visit your site to check.

Option B: your child theme

Add this to your child theme's functions.php (editing a parent theme directly is lost on updates):

add_action( 'wp_head', function () {
    ?>
    <script defer src="https://t.usehonestcount.com/script.js" data-website-id="YOUR-WEBSITE-ID"></script>
    <?php
} );

To skip counting your own visits while logged in, wrap the output in if ( ! is_user_logged_in() ) { … }.

Google Tag Manager

Tag Manager's Custom HTML tags do not reliably keep data- attributes on script tags, so load the tracker with a few lines of JavaScript instead:

  1. Create a new tag of type Custom HTML.
  2. Paste the code below, replacing the ID.
  3. Set the trigger to Initialization - All Pages (or All Pages), save, then preview and publish your container.
<script>
  (function () {
    var s = document.createElement('script');
    s.defer = true;
    s.src = 'https://t.usehonestcount.com/script.js';
    s.setAttribute('data-website-id', 'YOUR-WEBSITE-ID');
    document.head.appendChild(s);
  })();
</script>

Do not also add a history-change trigger: the tracker already counts single-page-app navigation on its own, and a second trigger would double-count pageviews.

Tracker options

Add these optional attributes to the script tag. They are standard Umami tracker options.

AttributeWhat it does
data-domains="example.com,www.example.com"Only count visits on these hostnames. Useful to keep staging and localhost out of your numbers and your event allowance.
data-auto-track="false"Turn off automatic pageviews and events; you call umami.track() yourself.
data-do-not-track="true"Respect the visitor's browser Do Not Track setting.
data-exclude-search="true"Drop the query string from recorded URLs.
data-exclude-hash="true"Drop the #hash from recorded URLs.
data-tag="variant-b"Tag every event from this page, for example to compare two versions of a landing page.

Content Security Policy

If your site sends a Content-Security-Policy header, allow our tracker host for scripts and for the requests it sends:

script-src  'self' https://t.usehonestcount.com;
connect-src 'self' https://t.usehonestcount.com;
img-src     'self' https://t.usehonestcount.com;   # only if you use tracking pixels