Back to Arky

Page Views

Count page views, pages, countries, referrers and unique visitors with one beacon that stores nothing.

Page views are counted, not recorded. The SDK sends each view as one beacon, and Arky adds it to the store’s counts and keeps nothing else: no customer, session, action or record, and nothing in the visitor’s browser.

Tip

Page views are not actions. Count traffic with pageViews.send, and track outcomes such as lead.submitted with actions.track.

Send A Page View

Call pageViews.send once for each page the visitor sees: when the page loads, and after each client-side navigation in a single-page app.

let landed = false;

export function countPageView() {
arky.pageViews.send({
  path: location.pathname,
  referrer: landed ? null : document.referrer,
});
landed = true;
}
  • path is the page’s path. Arky keeps it without query or fragment, so /products/a?utm_source=mail#reviews counts as /products/a.
  • referrer is the browser’s document.referrer. Send it with the first page of a visit only: the browser keeps the same referrer during client-side navigation.

The SDK uses navigator.sendBeacon with a text body that carries the publishable key, the path and the referrer, because a beacon can’t send headers. The view leaves even while the page is closing, and it needs no CORS preflight. The call sends no session or customer ID, never creates a visitor session, and writes no cookie or local storage. It throws outside a browser, and when the browser does not queue the beacon. Any other field in the body is refused.

What Arky Counts

  • Page views per day and month, in total, per page, per country and per referrer.
  • Unique visitors per day and month. For each view Arky derives a visitor key from the store, the client’s network address and its User-Agent, and adds the key to a HyperLogLog sketch (about ±1.6%). The key, the address and the User-Agent are never stored, logged or sent anywhere: only the sketch remains, and no visitor can be read out of it. The same browser on the same network counts once in a day, a month or any span read together; a view whose client address is unknown counts as a view but not a visitor.
  • A referrer counts only as another site’s host: https://www.google.com/search?q=shoes counts as www.google.com. An empty referrer and a page of your own site count no referrer.
  • The country comes from the network edge in front of Arky. ZZ means unknown.
  • Days and months are the store’s local days, in the store’s timezone.

There is no device breakdown, and no visitor count per page, country or referrer. Page views can’t be recounted later, because views are not records.

Delivery And Limits

  • Each Arky server adds views up in memory and publishes every minute once it ends, so a view shows in Admin shortly after its minute. A crashed server loses only the views it had not published.
  • Views are rate-limited per client address and per publishable key. A refused beacon (429) counts nothing.
  • A page path is at most 512 bytes. Arky refuses a malformed view with 400: PAGE_VIEW.INVALID_PATH (the path must start with /) and PAGE_VIEW.INVALID_REFERRER (the referrer must be an absolute URL with a host); a body with any other field is 400 GENERAL.BAD_REQUEST. An unknown or revoked key is refused with 401.

Read The Numbers

Admin’s Analytics page shows page views, top pages, countries, referrers and unique visitors for any span of days. The numbers come from the store’s counts, kept as views arrive; reading them needs the analytics permission.