Web script

One tag, about 1 KB gzipped. It records pageviews, client-side route changes, referrers and campaign tags, and sets no cookies.

Install

index.html
<script defer src="https://api.pagebee.ai/script.js" data-site="pb_pk_your_site_key"></script>

Attributes

AttributeDefaultWhat it does
data-siterequiredThe property's public site key
data-envunsetproduction, staging or preview. Unset lets the hostname rules decide
data-apithe script's originSend events somewhere else, such as your own proxy
data-auto="false"onTurn off automatic pageviews and call pagebee() yourself
data-hashoffCount #/routes as pages, for hash routers
data-localoffRecord on localhost and 127.0.0.1, which are skipped by default

Custom events

js
pagebee("Signed up", { props: { plan: "pro" } });
pagebee("Purchase", { revenue: 1999, currency: "GBP" }); // 19.99, in minor units

To queue calls made before the script loads, add this above the tag:

html
<script>window.pagebee=window.pagebee||function(){(pagebee.q=pagebee.q||[]).push(arguments)}</script>

No-code events

Any element with data-pagebee-event records an event when clicked, and a form records on submit.

html
<a href="/pricing" data-pagebee-event="Pricing CTA" data-pagebee-prop-location="hero">See pricing</a>
<form data-pagebee-event="Newsletter signup">...</form>
<button data-pagebee-event="Tip" data-pagebee-revenue="300" data-pagebee-currency="GBP">Tip £3</button>

What it doesn't do

  • No cookies, local storage, session storage or fingerprinting.
  • Nothing is sent when Do Not Track or Global Privacy Control is on.
  • Query strings are cut back to utm_*, ref and source before sending, so tokens and emails in URLs never leave the browser.
  • localhost, 127.0.0.1 and automated browsers are skipped.

Content Security Policy

If your site sends a CSP header, allow the API host in script-src and connect-src:

text
script-src 'self' https://api.pagebee.ai;
connect-src 'self' https://api.pagebee.ai;