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
| Attribute | Default | What it does |
|---|---|---|
data-site | required | The property's public site key |
data-env | unset | production, staging or preview. Unset lets the hostname rules decide |
data-api | the script's origin | Send events somewhere else, such as your own proxy |
data-auto="false" | on | Turn off automatic pageviews and call pagebee() yourself |
data-hash | off | Count #/routes as pages, for hash routers |
data-local | off | Record 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 unitsTo 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_*,refandsourcebefore sending, so tokens and emails in URLs never leave the browser. localhost,127.0.0.1and 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;