Skip to main content
To install HelpAlive in an Angular app, you add one script tag to src/index.html and wrap HelpAlive in a small injectable service. Then you call identify() when your auth state has a signed-in user, and reset() in your logout code. This page works for Angular apps with standalone components or NgModules, with or without server-side rendering.

Before you start

  • Your project key, from Settings → Setup & API Key. It is public, so it is safe to put in your front-end code.
  • The service that holds the signed-in user, for example an AuthService with a user signal or a user$ observable.
  • About 10 minutes.

How to install HelpAlive in Angular

1

Add the tag to src/index.html

Paste the tag before </head> in src/index.html:
src/index.html
Replace YOUR_PROJECT_KEY with your key.
2

Create the HelpAlive service

Create src/app/helpalive.service.ts. It queues calls made before the script has loaded, and the script replays them in order when it arrives:
src/app/helpalive.service.ts
3

Call identify() from your auth state

In your root component, call identify() whenever the signed-in user is set. With a signal, use an effect:
src/app/app.component.ts
With an observable, subscribe to user$ in the same place and make the same call for each user it emits. Fill the fields from your own user and company objects, and delete the ones your app doesn’t have. Identify users describes each field.
4

Call reset() at logout

Put reset() in the method that signs the user out:
src/app/auth.service.ts
Also call it where your app finds out a session has ended, usually in an HTTP interceptor that sees a 401:
src/app/session.interceptor.ts

Why run HelpAlive outside the Angular zone?

HelpAlive works in the background while your user is on the page. If HelpAlive started that work inside the Angular zone, Angular would run change detection more often than it needs to. The work could also keep your app from reaching a stable state, which server-side rendering and service workers wait for. runOutsideAngular keeps HelpAlive’s work out of Angular’s change detection. In a zoneless app it does no harm.

Why does the service check for the browser?

With Angular SSR, your components and services also run on the server, where window does not exist. isPlatformBrowser makes the service skip every call there, and the browser makes the same calls once the app starts on the client.

How do I add the nonce for a Content Security Policy?

Angular’s ngCspNonce attribute covers the styles Angular adds itself, not our script tag. Have your server put the page’s nonce on the HelpAlive tag as a nonce attribute, the same way it fills in ngCspNonce. Also add HelpAlive’s sources to your policy. Content Security Policy lists the sources.

Do I need to tell HelpAlive about route changes?

No. HelpAlive records a page view whenever the Angular router changes the address, with the default path routing or with HashLocationStrategy. There is nothing to call in a guard or a router event.

Check that it works

Sign in to your app with a test account, then open Settings → Setup & API Key on the dashboard. The first step, Add HelpAlive to your app, gets a check once HelpAlive has seen your page and a signed-in user. Check it works explains each step. To see what HelpAlive does on a page, add data-debug to the tag while you test, and remove it before you ship.

Verify users

Verifying users is optional and recommended. Your server signs a token for the signed-in user, and your app passes it to identify() in place of userId and tenantId. Verify users shows how to create the signing secret and sign the token in your server’s language. Add the token to what your current-user endpoint returns, for example /api/me. Send that response with Cache-Control: no-store. Then pass the token in your root component’s effect:
src/app/app.component.ts
HelpAlive calls refreshUserToken when a token expires, so you need it only if your tokens have an exp. If your endpoint can’t make a token, for example after an error, pass userId and tenantId as in step 3. Keep reset() in your logout code: it also forgets the token.

Next

Identify users

Every identify() field, switching company, and logout.

Verify users

Add a signed token so nobody can use the agent as someone else once Only allow verified users is on.

Troubleshooting

When the agent doesn’t appear.
Last modified on November 26, 2026