# Script tag

Put this tag in the `<head>` of every page. The app's **Install** page shows it with your site id.

```html
<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, which it sees through the Navigation API, or through the History API in browsers without it;
- 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.

## Attributes

| Attribute       | Use                                                                                                                                 |
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `data-site`     | Your site id. Required, except behind a [first-party proxy](./proxy.md).                                                            |
| `data-endpoint` | Where events go. Default: the host the script came from. Set it for a [custom domain](./custom-domain.md) or a [proxy](./proxy.md). |
| `data-hash`     | Count `#hash` changes as page views, for apps that route by hash.                                                                   |
| `data-manual`   | Send no page views on its own. Call `crowne.pageview()` yourself.                                                                   |

## crowne(name, props?)

The script defines a global `crowne` function that sends a [custom event](./events.md):

```js
crowne("signup", { plan: "pro" });
```

## crowne.pageview(url?)

Sends a page view, for the current address or for `url`. Use it with `data-manual` when your framework knows when it shows a page:

```js
crowne.pageview();
crowne.pageview("https://example.com/checkout/done");
```
