Skip to main content
In an Angular app, the simplest way to install Radar is to paste the script into src/index.html. Every screen of the app is served from that one file, so the script loads everywhere. Replace pk_xxxx with your project key.
src/index.html
Do not write an HTML comment inside the tag, next to the attributes: it breaks the script. For what each attribute does, see how the script works.

Alternative: load it from a service

Use this version when you want to read the project key from your environment files. The service adds the script to the document head. It does nothing when the key is empty or when the script is already on the page.
src/app/core/radar.service.ts
Call the service when the app starts, with APP_INITIALIZER. Pick the tab that matches how your app is bootstrapped.

Keep the key out of development

With the service, store the key in your environment files and leave it empty for development. Without a key, the script is not added to the page, so Radar does not load while you develop.
Both files live in src/environments. Their names depend on how your project is set up: projects created with a recent Angular CLI use environment.development.ts for development and environment.ts for production. Put the empty key in the development file.

Check that it works

Deploy your site, open the published version, load two pages and click a link. The first event should reach your Radar dashboard within a few seconds. If nothing arrives, follow check your installation. When the tag is added by JavaScript rather than written in the HTML, it does not show in the raw page source: look for tracker.js in the Elements panel of your browser’s developer tools instead.