# Install on Angular

> Add Reveata to an Angular app through src/index.html.

An Angular app is served from `src/index.html`, so the snippet goes there once.

Copy the snippet from your Reveata dashboard (it contains your website’s tracking id):

```html
<script
  defer
  data-website-id="ws_your_tracking_id"
  src="https://reveata.com/js/script.js"
></script>
```

## Add it to your app

Paste it before `</head>` in `src/index.html`:

```html
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>My app</title>
    <base href="/" />
    <script defer data-website-id="ws_your_tracking_id" src="https://reveata.com/js/script.js"></script>
  </head>
  <body>
    <app-root></app-root>
  </body>
</html>
```

`ng build` keeps the tag in the built `index.html`, with server-side rendering too.

The Angular Router changes pages through the History API, which the script follows, so every route is counted. With `HashLocationStrategy` (URLs like `/#/settings`), add `data-hash="true"` to the tag.

## Check it works

Open your deployed app in a private window, then check that the visit appears in your Reveata dashboard. If it doesn’t, follow [Verify your installation](https://reveata.com/docs/verify-your-installation). Visits to `ng serve` on `localhost` are ignored unless you add `data-allow-localhost="true"`.

## Goals

Templates accept the attribute as it is:

```html
<button type="button" data-reveata-goal="start_trial" data-reveata-goal-plan="pro">
  Start free trial
</button>
```

For a value that changes, bind it with `[attr.data-reveata-goal-plan]="plan"`. From a component, call the script:

```ts
startTrial(plan: string) {
  (window as any).reveata?.('goal', 'start_trial', { plan });
}
```

See [Custom goals](https://reveata.com/docs/custom-goals).

## Revenue

Connect your payment provider in Reveata: see [Connect a payment provider](https://reveata.com/docs/connect-a-payment-provider). Send `window.reveata.metadata()` to your server with the request that creates the checkout.
