Skip to Content
Pageflock

Script tag

One line of HTML for static sites, CMSs and anything without a build step.

Add this to the <head> of every page:

<script defer src="https://e.pageflock.com/s.js" data-site="SITE_ID"></script>

The script is under 1 KB gzipped. It records page views (including single-page app navigations), custom events, time on page and how far down each page visitors scroll.

Two builds

ScriptRecords
s.jsPage views, custom events, time on page, scroll depth
s.auto.jsAll of the above, plus outbound link clicks, file downloads and 404 pages

Attributes

AttributeWhat it does
data-siteYour site's ID. Required.
data-apiThe collect endpoint. Defaults to /api/e on the script's own origin, so you only need it in unusual setups.
data-hashCount #hash changes as page views, for hash-routed apps.

Self-hosting? Load the script from your own ingest Worker, for example https://in.example.com/s.js, and it sends events there.

Custom events

window.pageflock.track("Signup", { plan: "pro" });

Or without JavaScript:

<button data-track="Signup" data-track-plan="pro">Sign up</button>

See Custom events for more.

From npm

The same tracker is on npm as @pageflock/tracker, if you would rather bundle it yourself:

import { init } from "@pageflock/tracker";

const pageflock = init({ site: "SITE_ID" });
pageflock.track("Signup", { plan: "pro" });

For React, Next.js, Vue and other frameworks, @pageflock/analytics is easier to set up.

On this page