GuidesWeb

HTML script tag analytics, cookieless and hosted in the EU

Two script tags, no build step, no cookies. Works on any HTML page.

Privytics records page views and custom events on any HTML page through a single script tag. You paste two tags into your `<head>`, set `apiUrl` to `https://api.privytics.com` and your client id, and page views start arriving. Privytics runs on the open-source OpenPanel engine, so the browser global is `window.op` and the tracker file is `op1.js`.

Why HTML / Script tag teams use Privytics

No build step, no bundler

The snippet is plain HTML. It runs anywhere you can edit a template or inject a header script: static sites, a CMS theme, a landing page, an nginx-served folder. There is nothing to install, compile or deploy alongside your app.

Page views work without a router

Set trackScreenViews: true and navigation is captured for you. On a classic multi-page site every click is a real page load, and the tracker also patches the history API and listens for popstate, so a site that later gains client-side routing keeps reporting screen views without new code.

Instrument clicks from markup alone

With trackAttributes: true, any button or anchor carrying a data-track attribute fires an event on click, and its other data-* attributes become event properties. A designer editing templates can add tracking without touching JavaScript.

Nothing is written to the device

The script sets no cookies and stores no identifier in the browser. Visitors are counted with an anonymous id that resets every day. That removes the usual work of gating a snippet behind a consent management platform on an otherwise static site.

Set it up

About five minutes, on the free plan, without a credit card.

  1. Add the snippet to your HTML

    Paste both tags into the <head> of every page, or into your template's shared header. Replace YOUR_CLIENT_ID with the client id from your Privytics project. Setting apiUrl is required: if you leave it out, the SDK falls back to OpenPanel's own hosted API instead of yours.

    <script>
      window.op=window.op||function(){var n=[];return new Proxy(function(){arguments.length&&n.push([].slice.call(arguments))},{get:function(t,r){return"q"===r?n:function(){n.push([r].concat([].slice.call(arguments)))}} ,has:function(t,r){return"q"===r}}) }();
      window.op('init', {
        apiUrl: 'https://api.privytics.com',
        clientId: 'YOUR_CLIENT_ID',
        trackScreenViews: true,
        trackOutgoingLinks: true,
        trackAttributes: true,
      });
    </script>
    <script src="https://privytics.com/op1.js" defer async></script>
  2. Track a custom event

    Call window.op('track', ...) with an event name and any properties you want to filter or group by later. Calls made before op1.js finishes loading are pushed onto a queue by the stub in step one and replayed once the tracker loads, so you can track from anywhere on the page.

    window.op('track', 'signup_completed', {
      plan: 'free',
      source: 'pricing_page',
    });
  3. Track clicks without writing JavaScript

    Because you enabled trackAttributes, a data-track attribute on a button or link sends that event on click. Every other data-* attribute on the element is passed along as an event property.

    <button
      data-track="signup_completed"
      data-plan="free"
      data-source="pricing_page"
    >
      Create account
    </button>
  4. Identify a signed-in user

    Optional. Pass your own user id as profileId to link sessions into one profile. This is opt-in and you need your own lawful basis for it. Call window.op('clear') on logout to stop attributing events to that profile.

    window.op('identify', {
      profileId: '123',
      firstName: 'Joe',
      lastName: 'Doe',
      email: 'joe@doe.com',
      properties: {
        tier: 'premium',
      },
    });

Privytics runs the open-source OpenPanel engine, so the upstream HTML / Script tag SDK reference applies here too. Point apiUrl at Privytics and the data lands in your Privytics project.

Questions

How do I add analytics to a plain HTML website?

Paste the two script tags from step one into the <head> of your pages and set clientId and apiUrl. With trackScreenViews: true, page views are recorded from the next load onwards. No package manager or build tooling is involved.

Does the script tag set any cookies?

No. The tracker sets no cookies and stores no identifier on the device. Visitors are counted using a salted hash of IP address, user agent and project id, and that salt is rotated once a day, at midnight UTC.

Can I track button clicks without writing JavaScript?

Yes. Set trackAttributes: true in the init call, then add data-track="event_name" to a button or anchor. Any other data-* attributes on that element are sent as properties of the event.

Do I still need a cookie banner?

That is your call as the data controller, and we cannot make it for you. What we can describe is the design: the default script writes nothing to the device and sends no cookie, and the visitor identifier is a salted hash that is rotated daily rather than a stored id. If you enable identify() with your own user ids, you are processing identifiable data and need your own lawful basis.