Put this tag in the <head> of every page. The app's Install page shows it with your site id.
<script defer src="https://in.crowne.io/v1/script.js" data-site="YOUR_SITE_ID">
</script>The script is less than 2 KB. It sends a page view:
- when the page loads;
- on each in-app navigation through the History API;
- when the browser restores a page from its back/forward cache.
crowne counts events only from the site's domains and their subdomains. It drops bots and prerendered pages.
Options
Set these attributes on the tag.
| Attribute | Use |
|---|---|
data-site |
Your site id. Required. |
data-hash |
Count #hash changes as page views, for apps that route by hash. |
data-endpoint |
Send events to this address, not to the host the script came from. |
Custom events
The script defines a global crowne function. Call it with an event name and, if you want, properties.
crowne("signup", { plan: "pro" });See Custom events for names, properties, and goals.
Send events to your endpoint
By default, events go to the host the script came from. Set data-endpoint to send them to your custom domain or to a proxy path on your site.
<script
defer
src="https://in.crowne.io/v1/script.js"
data-site="YOUR_SITE_ID"
data-endpoint="/api/event"
>
</script>This helps only a little: a blocker that blocks in.crowne.io blocks the script itself, so no events go anywhere. To keep the script and the events off crowne's hosts, use the npm package, a custom domain, or the proxy. See Ad blockers.