Skip to content
Skip to main content
European Data Processing
← All platform guides

Install on HTML / Any Website

One script tag in a shared layout counts every page on the site, and sends the click, scroll and engagement events from all of them.

Before you paste anything

Every snippet below shows YOUR-SITE-ID . Replace it with your own site id, which is on the Tracking Code page of the site in your account. If you do not have an account yet, creating one and adding your domain takes about a minute.

Create a free account

Which method should you use?

  1. 1. Add the script tag

    Use this unless you cannot run JavaScript at all. It counts pages and also records clicks, scroll depth, engaged time and Core Web Vitals, which the image on its own cannot.

  2. 2. Image only, no JavaScript

    Choose this only where a script is impossible: a content policy that forbids one, an email or a feed, or a page you cannot add JavaScript to. It records pageviews and nothing else. No clicks, no goals, no engaged time, no scroll depth, no Core Web Vitals, and no single-page-app navigations, so bounce rate and time on page will not be meaningful.

Add the script tag

  1. Open the template, layout or include that every page on the site shares.
  2. Paste the snippet immediately before the closing </head> tag.
  3. Deploy the change and load any page on the site.
layout.html
<script>
  (function () {
    // Ensure this only runs in a browser environment.
    if (typeof window === 'undefined' || typeof document === 'undefined') {
      return;
    }

    var siteId = 'YOUR-SITE-ID';
    var trackingDomain = 'www.veritametrics.com'; // 1. Initialize the Async Command Queue
    // This ensures window.verita() is available immediately.
    window.verita =
      window.verita ||
      function () {
        (window.verita.q = window.verita.q || []).push(arguments);
      };
    window.verita.l = new Date().getTime(); // 2. Load the enhanced tracker script asynchronously.
    // It will process the command queue once loaded.

    var script = document.createElement('script');
    script.src = 'https://' + trackingDomain + '/api/tracker.js?siteId=' + siteId;
    script.async = true;
    script.defer = true;
    script.dataset.siteId = siteId;
    script.dataset.trackingDomain = trackingDomain;
    document.head.appendChild(script); // 3. Send the initial pageview using the *queue*

    window.verita('trackPageView');
  })();
</script>
<noscript>
     
  <img
    src="https://www.veritametrics.com/api/track-pageview?siteId=YOUR-SITE-ID"
    referrerpolicy="unsafe-url"
    alt=""
    width="1"
    height="1"
    style="display: none"
    aria-hidden="true"
  />
</noscript>

Note: The <noscript> pixel at the end counts visitors with JavaScript turned off. Nothing in it needs substituting: it carries referrerpolicy="unsafe-url", so the page URL reaches us in the Referer header even on a static site with no server to fill one in.

Image only, no JavaScript

  1. Open the template, layout or include that every page on the site shares.
  2. Paste the image tag anywhere inside the page.
  3. Deploy the change and load any page on the site.
layout.html
<!-- 
  VeritaMetrics Analytics - Basic Tracking Pixel 

  Instructions:
  The page URL is taken from the Referer header this tag sends, which is
  why referrerpolicy="unsafe-url" is on it: the browser default sends only
  the origin cross-origin and the path would be lost. Nothing to substitute.
  If you render server-side you may add &url=<full URL> and &ref=<referrer>
  and those win over the header.
-->
<img
  src="https://www.veritametrics.com/api/track-pageview?siteId=YOUR-SITE-ID"
  referrerpolicy="unsafe-url"
  alt=""
  width="1"
  height="1"
  style="display: none"
  aria-hidden="true"
/>
<!-- End VeritaMetrics Analytics -->

Note: One request per page load, and no script. The page URL arrives in the Referer header, which is why the tag carries referrerpolicy="unsafe-url".

Check that the data is arriving

  1. Open your site in a browser and load any page.
  2. In VeritaMetrics, open the site and click Tracking Code in the sidebar. The status turns active and your visit appears in the recent-pageviews list within a few seconds.

If nothing arrives, open your browser devtools on the Network tab and reload. You should see a request to /api/tracker.js that returns 200, then a request to /api/v1/c when you move or scroll.

The snippet on one page only counts one page

Pasting the tag into a single HTML file tracks that file. Every other page reports nothing, and the dashboard looks like a site with one popular page and no traffic anywhere else. Put the tag in the layout, template or include that every page pulls in.

Guides for other platforms

The same install, on a different stack.

Explore the documentation

Jump to another guide.