crowne has four ways to send events. Most sites need only one; a site can use more than one, such as the script tag for page views and the server package for payments.
| Method | Use it when | Counts page views on its own | Needs a key |
|---|---|---|---|
| Script tag | You can edit your pages' HTML. The quickest start. | Yes | No |
| npm package | Your app has a bundler, and you want no third-party script. | Yes | No |
| Server package | The action happens on your server, or your pages run no script. | No | Yes |
| REST API | Any other language or platform, with no package. | No | For servers |
Script tag
One line in your pages' <head>. It counts page loads, in-app navigation, and back/forward restores, and gives your pages a global crowne() for custom events. Use it on any site where you can edit the HTML, including sites from a site builder.
npm package
crowne/browser does what the script tag does, from inside your bundle. Use it in apps with a bundler, such as React or Svelte apps, when you want typed calls and no extra script request.
Server package
crowne/server sends events from a server, such as a Cloudflare Worker or Node, with a secret key. Use it for actions the browser does not see, such as a payment or an API call, and for pages that run no script. It also serves the first-party proxy.
REST API
Every package calls the REST API. Call it yourself from any language: a browser can send events with only the site id, and a server sends them with a key.
Fewer blocked visits
Any of the browser methods can load and send through your own domain, so ad blockers drop fewer visits. See Ad blockers.